Using a x86 chroot to run 32 bit apps on Debian AMD64
Unfortunatelly today’s internet sites usually depend heavily on Macromedia Flash to “enhance” the experience. Therefore it was not too much fun working on my 64 bit Linux system the last couple of days, because the browser was displaying a lot of “please download plugin” signs and after a while they got on my nerves. Since there is no 64bit Flash plugin for firefox I chose to resort to a 32bit chroot environment to run my iceweasel in. Here’s what I did:
mkdir /chroot-sid-i386
debootstrap --arch i386 sid /chroot-sid-i386 http://ftp2.de.debian.org/debian/
That sets up a basic Debian i386 environment using sid (unstable).
To get transparent mount and environment settings there are a couple of things to set up.
Change /etc/fstab and append following lines:
# ia32 chroot
/home /chroot-sid-i386/home none bind 0 0
/tmp /chroot-sid-i386/tmp none bind 0 0
/proc /chroot-sid-i386/proc none bind 0 0
/dev /chroot-sid-i386/dev none bind 0 0
/media/cdrom0 /chroot-sid-i386/media/cdrom0 none bind 0 0
/usr/share/fonts /chroot-sid-i386/usr/share/fonts none bind 0 0
Now execute the following commands:
mkdir /chroot-sid-i386/media/cdrom0
mkdir /chroot-sid-i386/usr/share/fonts
mount -a
cp /etc/passwd /etc/shadow /etc/group /etc/environment /chroot-sid-i386/etc/
apt-get install dchroot
Now add your favourite Debian mirror to the chroot’s apt source.list:
# vim /chroot-sid-i386/etc/apt/sources.list
deb http://ftp2.de.debian.org/debian/ sid main contrib non-free
deb-src http://ftp2.de.debian.org/debian/ sid main contrib
and finally go into the chroot for the first time:
chroot /chroot-sid-i386
Maybe it’s a good thing to check your environment first:
dpkg-reconfigure locales
And usually it is a good idea to install some basic stuff:
tasksel --new-install
Make sure “Standard system” is selected. Usually it is a good idea to not select all the other stuff. Since usually those are already installed in your regular environment and might just be dead weight on your harddrive.
As an alternative you can install that task without an interface by using
tasksel install standard
Well, now let’s update apt-get and install some stuff.
apt-get update
apt-get install firefox
And that’s basically it.
To make it easier for normal user to access the chroot and execute 32 bit programs set up dchroot correctly:
(While in the non-chroot env):
Create /etc/dchroot.conf with the following content:
# sid386 chroot
sid386 /chroot-sid-i386
Create a file /usr/local/bin/do_chroot with the following content:
#!/bin/sh
ARGS=""
for i in "$@" ; do
ARGS="$ARGS '$i'"
done
exec dchroot -c sid386 -d -q "`basename $0`" "$ARGS"
Now linking a name in /usr/local/bin to do_chroot via logical symlink executes the program with the same name within the chroot. Without the need of super-user rights.
My symlinks look like this (I added an additional 86 at the end of each name to avoid name conflicts):
/usr/local/bin$ ls -l
total 4
lrwxrwxrwx 1 root staff 9 May 16 11:09 acroread86 -> do_chroot
-rwxr-xr-x 1 root staff 114 May 16 10:40 do_chroot
lrwxrwxrwx 1 root staff 9 May 16 10:44 iceweasel86 -> do_chroot
and
/chroot-sid-i386/usr/bin$ ls -l acroread* iceweasel*
lrwxrwxrwx 1 root root 40 May 16 11:08 acroread -> /usr/local/Adobe/Acrobat7.0/bin/acroread
lrwxrwxrwx 1 root root 8 May 16 11:11 acroread86 -> acroread
lrwxrwxrwx 1 root root 26 May 15 17:45 iceweasel -> ../lib/iceweasel/iceweasel
lrwxrwxrwx 1 root root 9 May 15 17:52 iceweasel86 -> iceweasel
Additionally any user can now execute a bash shell inside the chroot environment by using:
dchroot -c sid386 -d
This setup should work on any Debian setup. I personally tested it on etch and lenny.

I see the browser changes the dashes.
Comment on July 14, 2007 @ 20:28:09