Building a Debian chroot image

From WebOS Internals
(Redirected from Debian)
Jump to navigation Jump to search

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. <source lang="bash"> dd if=/dev/zero of=DebianSqueeze_armel.img bs=1M count=512 mkdir build </source>

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] <source lang="bash"> losetup -f losetup -f DebianSqueeze_armel.img mkfs.ext2 /dev/[device] </source>

Building a system

Now we can fill the image with Magic *cough* I mean Debian 6.0.x "squeeze" <source lang="bash"> mount /dev/[device] build/ debootstrap --arch armel --foreign squeeze build/ </source>

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. <source lang="bash"> cp /usr/bin/qemu-arm-static build/usr/bin/ chroot build/ /debootstrap/debootstrap --second-stage </source>

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

<source lang="bash"> apt-get clean echo "deb squeeze main" > /etc/apt/sources.list </source>

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. <source lang="bash"> echo 'APT { Install-Recommends "false"; };' > /etc/apt/apt.conf.d/50no-recommends </source>

Exit the chroot <source lang="bash"> exit </source>

Cleaning up

A few steps to clean up on your desktop. <source lang="bash"> rm build/usr/bin/qemu-arm-static umount build/ losetup -d /dev/[device] </source>


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