Difference between revisions of "Building a Debian chroot image"

From WebOS Internals
Jump to navigation Jump to search
(updating dirctory names to be consistant)
Line 24: Line 24:
 
<source lang="bash">
 
<source lang="bash">
 
mount /dev/[device] build/
 
mount /dev/[device] build/
debootstrap --arch armel --foreign squeeze mnt/ http://ftp.us.debian.org/debian
+
debootstrap --arch armel --foreign squeeze build/ http://ftp.us.debian.org/debian
 
</source>
 
</source>
  
 
At this point the system is only partially setup.  This next step 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.
 
At this point the system is only partially setup.  This next step 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">
 
<source lang="bash">
cp /usr/bin/qemu-arm-static mnt/usr/bin/
+
cp /usr/bin/qemu-arm-static build/usr/bin/
chroot mnt/
+
chroot build/
 
/debootstrap/debootstrap --second-stage
 
/debootstrap/debootstrap --second-stage
 
</source>
 
</source>
Line 54: Line 54:
 
A few steps to clean up on your desktop.
 
A few steps to clean up on your desktop.
 
<source lang="bash">
 
<source lang="bash">
rm mnt/usr/bin/qemu-arm-static
+
rm build/usr/bin/qemu-arm-static
umount mnt/
+
umount build/
 
losetup -d /dev/[device]
 
losetup -d /dev/[device]
 
</source>
 
</source>

Revision as of 02:29, 30 March 2011

Having a custom image for your 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, as 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 at root. <source lang="bash"> losetup -f </source> Note the loop device output by this, it will probably be loop0 and in the examples below this is what you'll put in for [device] <source lang="bash"> 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/ http://ftp.us.debian.org/debian </source>

At this point the system is only partially setup. This next step 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 http://ftp.us.debian.org/debian 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>

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