Sunday, March 26, 2006

Running Ubuntu Dapper packages on Breezy using chroot


I prefer it if things Just Work™ whenever I need them to, however sometimes I need to use things that are on the cutting edge. Unfortunately in the open source world, 'reliability' and 'cutting edge' tend to be mutually exclusive. Ubuntu 'breezy' is by far the easiest and most reliable linux distro I have used. In my opinion the maintainers have achieved just the right balance - users can have both a functional and stable desktop.

My favourite video reprocessing tool, Avidemux, is not available on 'breezy'. It depends on libraries that are only available as packages in 'dapper' (the next release of Ubuntu). Unfortunately 'dapper' has been delayed 6 weeks until 1st June 2006. I couldn't wait that long to process the gigabytes of digital TV I have piling up, waiting to archive. I toyed with apt-pinning my 'breezy' install and installing the 'dapper' packages, but it was going to break things majorly.Recently I hit on an idea: Debian can be made to run 32-bit binary code on an EMT/AMD64-bit install by using a chroot jail. I know chroot can be used for wider purposes not limited to the situation above, so i set about googling. Surprisingly I turned up very little. Jump to the end for a couple of links I did find (including the Ubuntu forum describing running 32-bit code on 64-bit installs). By following a few examples, reading a bunch of 'man' pages and a bit of trial and error, I found a very functional solution. Avidemux is crunching away right now...


The solution is actually quite straight forward. As at 29th March 2006, 'Dapper Flight 5' installs very nicely into a chroot alongside 'breezy'.
  1. Get the latest Ubuntu 'debootstrap' package.
  2. Bootstrap a new 'dapper' install into /opt/dapper.
  3. Setup 'breezy' bindings into the 'dapper' chroot.
  4. Configure 'dchroot' if you want non-root users to access 'dapper'.
  5. Chroot into 'dapper' and 'apt-get update'.
  6. Finally 'apt-get install avidemux' or whatever packages you'd like.


First, I usually sudo into a root shell. That way you dont have to retype 'sudo' fifty times:

sudo bash
Make your desired chroot directory. I've chosen '/opt/dapper', choose your own if you like, however, adjust the rest of this document accordingly.

mkdir /opt/dapper
Install 'dchroot' and the 'debootstrap' packages:

apt-get install dchroot debootstrap
Try bootstrapping a dapper install:

root@orbit:/opt# debootstrap --arch i386 dapper /opt/dapper/
E: No such script: /usr/lib/debootstrap/scripts/dapper

The current 'debootstrap' doesnt include 'dapper' scripts. If yours doesn't either, browse the Ubuntu archives for the latest package. Copy its location then download and install the package:

root@orbit:/opt# wget
root@orbit:/opt# dpkg -i debootstrap_0.3.3.0ubuntu2_all.deb

Now bootstrap the 'dapper' install. You may not want to use the '.au' archives:

root@orbit:/opt# debootstrap dapper /opt/dapper/
I: Retrieving Release
I: Retrieving Packages
I: Validating Packages
I: Resolving dependencies of required packages...
I: Resolving dependencies of base packages...
I: Found additional required dependencies: belocs-locales-bin locales
I: Found additional base dependencies: libgnutls12 vim-runtime
I: Checking component main on
I: Configuring ubuntu-minimal...
I: Base system installed successfully.

This may take quite some time to download the packages.The 'dapper' chroot needs to be able to access certain files/paths in your 'breezy' install. This is achieved using 'mount' to bind paths into the chroot. Edit your /etc/fstab file so the bindings are done automatically on boot:

nano /etc/fstab
(paste at end)
/dev /opt/dapper/dev none bind 0 0
/proc /opt/dapper/proc none bind 0 0
/usr/share/fonts /opt/dapper/usr/share/fonts none bind 0 0
/media/cdrom0 /opt/dapper/media/cdrom0 none bind 0 0
/home/rob /opt/dapper/home/rob none rbind 0 0
/tmp /opt/dapper/tmp none bind 0 0
/etc/passwd /opt/dapper/etc/passwd none bind 0 0
/etc/shadow /opt/dapper/etc/shadow none bind 0 0
/etc/group /opt/dapper/etc/group none bind 0 0
/etc/sudoers /opt/dapper/etc/sudoers none bind 0 0
/etc/hosts /opt/dapper/etc/hosts none bind 0 0

Make the missing mount points, I needed these:

mkdir -p /opt/dapper/usr/share/fonts
mkdir -p /opt/dapper/media/cdrom0
mkdir -p /opt/dapper/home/rob
touch /opt/dapper/etc/shadow
touch /opt/dapper/etc/hosts

Note I've used bind directly on my home folder '/home/rob'. My '/home' folder is actually a mount point for an LVM partition. For some very strange reason, binding this '/home' mount location to another location '/opt/dapper/home' only bound the hidden files in '/home/rob'. A 'ls' turned up no files, while 'ls -a' turned up only the '.' hidden files in my home folder. This had me stumped for an hour, and googling turned up no similar issues to this. Anyone any ideas? does this happen to anyone else? My solution was to bind a path that was inside the mounted '/home' directory, ie. '/home/rob'. Note also that I have used 'rbind' for this mount to recursively bind other partitions that are mounted inside '/home/rob'. See the mount manpage.

Mount and check the bind paths:

mount -a
mount | grep bind

Configure 'dchroot': (Note I'm only using a single dchroot and this command will unlist any others!)

echo "dapper /opt/dapper" > /etc/dchroot

Setting the flag below will alter the bash prompt so you know when you're inside your 'dapper' chroot:

echo 'orbit-dapper' > /opt/dapper/etc/debian_chroot
Now, still as root, try chroot'ing into your 'dapper' install:

root@orbit:~# chroot /opt/dapper/
(orbit-dapper)root@orbit:/# <-- note the bash prompt changed

Great! Now, to bring the install up to speed, we need to 'apt-get update'. Create the sources.list file and update:

echo "deb dapper main restricted universe multiverse" > /etc/apt/sources.list
echo "deb dapper-security main restricted universe multiverse" >> /etc/apt/sources.list
apt-get update
apt-get upgrade

Now as root inside your new 'dapper' chroot, install any packages you'd like, eg:

apt-get install avidemux
To start your 'dapper' chroot as a normal user, use 'dchroot -d'. You'll need to use the '-c' option if you have more than one dchroot setup. To launch avidemux:

dchroot -d

  • I'm using the Australian locale, and various scripts were throwing locale errors inside 'dapper'. As root in 'dapper' I simply reset to the standard POSIX locale using export, i'm not sure if this is correct, but it did stop the errors:
    export LANG='' export LANGUAGE=''
  • From the referenced links at the bottom of this page, you may want to try:
    dpkg-reconfigure locales
  • Note: You should be careful with updating fonts in 'dapper', since the '/usr/share/fonts' folder is mapped back to your 'breezy' install.


No comments:

Post a Comment