Building a Debian chroot image

Building your own image for a chroot can be quite handy especially if you would like to customize what comes pre-installed. The following steps should work as-is on a Debian Squeeze system. They should also work for Ubuntu, but the name of the qemu package that provides the necessary binary is different. Please see Debian chroot for instruction on how to actually use this image on the Pre.

Required packages: debootstrap, qemu-user-static, binfmt-support

Creating the image file
Pick a directory to work in on your desktop/laptop computer. All the commands are relative to the current directory so it shouldn't matter where, so long as you have write access.

Now to put an ext2 file system in that blank file. The rest of these steps require being run as root. Note the loop device output by the first command, it will probably be loop0 and in the examples below this is what you'll put in for [device]

Building a system
Now we can fill the image with Magic *cough* I mean Debian 6.0.x "squeeze"

At this point the system is only partially setup. This next step with debootstrap would have to be preformed on the Pre, but with the help of qemu and binfmt we can do that on our desktop as well.

Now that the base system is installed and set up there is some minor housekeeping that we can do before transferring everything to the Pre. First we will clear apt's cache and then add a default mirror to sources.list

This next step is entirely optional and if you don't understand what it will do to the default choices made by apt when installing packages then I strongly recommend skipping it. It is only useful to keep space usage down, but at the cost of functionality.

Exit the chroot

Cleaning up
A few steps to clean up on your desktop.

Tada!
Now you have an image of Debian Squeeze that you can use on your Pre. This is where you transfer the image to the USB drive and there are several ways to do that.

More Resources
deboostrab on the debian wiki

information about cross debbootstrap on the debian wiki

helpful guide on digriz.org.uk