Simple chroot instructions for debian squeeze
These commands create a very basic chroot environment on my ubuntu 10.04 laptop. It’s nice to create a dedicated build environment, isolate an application or (in my case) test building/deployment on debian machines locally.
On host machine, execute as root!:
# install deboostrap, only need to run this once
apt-get install debootstrap
# create chroot target dir, replace with desired name
cd /opt
mkdir squeeze_chroot
# install debian squeeze 64-bit, will take some time and download packages
debootstrap --arch amd64 squeeze /opt/squeeze_chroot/
# edit /etc/fstab, add these lines (I'm not mounting /home) and save file:
/tmp /opt/squeeze_chroot/tmp none bind 0 0
/proc /opt/squeeze_chroot/proc proc defaults 0 0
/dev /opt/squeeze_chroot/dev none bind 0 0
# bind-mount the chroot stuff
mount -a
Now a basic chroot environment is created, let’s enter it and customize it a little
# change into chroot
chroot /opt/squeeze_chroot
# you'll now be in the / directory of your chroot
pwd
# fix some basic stuff
apt-get update
apt-get install locales
# Select only en_US and en_GB variants. Choose en_US.UTF-8 as default
dpkg-reconfigure locales
So that’s it, you’re good to go. Install things like ‘build-essential’, ‘subversion’ and ‘git-core’ at your own convenience. Your homedir will be /root.
There’s plenty of customization to do (remember, this is a full working Debian install) but I’ll leave that as an exercise for the reader :)
If you want to exit your chroot, just enter
exit