Sunday, March 26, 2006

Running Ubuntu Dapper packages on Breezy using chroot

Background:

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...

Solution:

The solution is actually quite straight forward. As at 29th March 2006, 'Dapper Flight 5' installs very nicely into a chroot alongside 'breezy'.

Get the latest Ubuntu 'debootstrap' package.

Bootstrap a new 'dapper' install into /opt/dapper.

Setup 'breezy' bindings into the 'dapper' chroot.

Configure 'dchroot' if you want non-root users to access 'dapper'.

Chroot into 'dapper' and 'apt-get update'.

Finally 'apt-get install avidemux' or whatever packages you'd like.

Howto:

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.

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:

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:

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
avidemux&Notes:

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.