by richard on Fri, 12/09/2011 - 00:26

Being a software developer, and owning quite a few old computers (x86), I sometimes regret my choice of running a 64-bit operating system on my desktop. Then again, it allows me to use the full potential of my processor (whatever that may be - I'm not convinced that it's all that much better than running it 32-bit, but hohum), so I deal with it.

Having cut my metaphorical linux teeth on Gentoo, from before it had an automated installer, I'm no stranger to chroot. A wonderful command that allows you to isolate different installs of the operating system.

A chroot is by far the easiest way to compile 32-bit software on a 64-bit debian install (I know it's possible to install all the 32-bit libraries, but I've always found it to be a faff!).

Enter our friend debootstrap.

debootstrap allows you to create a minimal debian filesystem within a folder on your current system. If you look closely when installing Debian in the first place, you will notice that the installer uses debootstrap to set up your initial system.

It's really easy to use. You just need to point it at a directory, tell it what architecture and version you want to install, and point it at a mirror.

For example, to install a native chroot environment on a debian amd64 system, you would run

richard@nemo:~$ debootstrap squeeze /srv/chroot/squeeze-chroot http://ftp.uk.debian.org/debian

Thats basically telling it to bootstrap squeeze into the folder /srv/chroot/squeeze-chroot from the mirror http://ftp.uk.debian.org

If, however, you want a 32-bit environment on a 64-bit machine, and you want it from wheezy (testing) rather than squeeze (stable) then you would run

richard@nemo:~$ debootstrap --arch=i386 wheezy/srv/chroot/wheezy-chroot http://ftp.uk.debian.org/debian

You can then chroot into your new environment with

richard@nemo:~$ chroot /srv/chroot/wheezy-chroot /bin/bash

In order to make it usable, you would need to create the /dev layout, and mount the proc and sys filesystems. I'll cover them in another post!