Difference between revisions of "Building a Debian chroot image"
Ragingmind (talk | contribs) (updating dirctory names to be consistant) |
Ragingmind (talk | contribs) (Fixing some minor gramar oops-es and updating some wording to be more clear) |
||
Line 1: | Line 1: | ||
− | + | 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 | Required packages: debootstrap, qemu-user-static, binfmt-support | ||
==Creating the image file== | ==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, | + | 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"> | <source lang="bash"> | ||
dd if=/dev/zero of=DebianSqueeze_armel.img bs=1M count=512 | dd if=/dev/zero of=DebianSqueeze_armel.img bs=1M count=512 | ||
Line 10: | Line 10: | ||
</source> | </source> | ||
− | Now to put an ext2 file system in that blank file. '''The rest of these steps require being run | + | 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"> | <source lang="bash"> | ||
losetup -f | losetup -f | ||
− | |||
− | |||
− | |||
losetup -f DebianSqueeze_armel.img | losetup -f DebianSqueeze_armel.img | ||
mkfs.ext2 /dev/[device] | mkfs.ext2 /dev/[device] | ||
Line 27: | Line 24: | ||
</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 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"> | <source lang="bash"> | ||
cp /usr/bin/qemu-arm-static build/usr/bin/ | cp /usr/bin/qemu-arm-static build/usr/bin/ | ||
Line 41: | Line 38: | ||
</source> | </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. | + | 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"> | <source lang="bash"> | ||
echo 'APT { Install-Recommends "false"; };' > /etc/apt/apt.conf.d/50no-recommends | echo 'APT { Install-Recommends "false"; };' > /etc/apt/apt.conf.d/50no-recommends |
Latest revision as of 14:06, 30 March 2011
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/ http://ftp.us.debian.org/debian </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 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.