Building a Debian chroot image
From WebOS Internals
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
Contents |
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.
dd if=/dev/zero of=DebianSqueeze_armel.img bs=1M count=512 mkdir build
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]
losetup -f losetup -f DebianSqueeze_armel.img mkfs.ext2 /dev/[device]
Building a system
Now we can fill the image with Magic *cough* I mean Debian 6.0.x "squeeze"
mount /dev/[device] build/ debootstrap --arch armel --foreign squeeze build/ http://ftp.us.debian.org/debian
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.
cp /usr/bin/qemu-arm-static build/usr/bin/ chroot build/ /debootstrap/debootstrap --second-stage
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
apt-get clean echo "deb http://ftp.us.debian.org/debian squeeze main" > /etc/apt/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.
echo 'APT { Install-Recommends "false"; };' > /etc/apt/apt.conf.d/50no-recommends
Exit the chroot
exitCleaning up
A few steps to clean up on your desktop.
rm build/usr/bin/qemu-arm-static umount build/ losetup -d /dev/[device]
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.