Installing development chroot environments
This documentation was updated after the release of Debian squeeze in early 2011
First, install dchroot and debootstrap:
apt-get install dchroot debootstrap
Then, create the chroot directory:
mkdir -p /opt/chroot/squeeze-i386
Next, place the new chroot in /etc/dchroot.conf:
squeeze-i386 /opt/chroot/squeeze-i386
Edit /etc/fstab to make some filesystems available in the chroots:
proc /opt/chroot/squeeze-i386/proc proc defaults 0 0 devpts /opt/chroot/squeeze-i386/dev/pts devpts defaults 0 0 /home /opt/chroot/squeeze-i386/home none bind 0 0 /tmp /opt/chroot/squeeze-i386/tmp none bind 0 0
Note: prior to mid-2011, I never had to mount /dev/pts. As of that point, I started getting errors:
/home/pronovic> su - root su: must be run from a terminal
Mounting devpts solves the problem. See also: [http://snorriheim.dnsdojo.com/doku/doku.php/en:linux:admin:chroots:chroots]
Anyway, once you've modified /etc/fstab, mount all entries that you added, so they're available to the chroot.
Then, create the chroot:
debootstrap --arch=i386 squeeze /opt/chroot/squeeze-i386
Set root's password:
dchroot -c squeeze-i386 /usr/bin/passwd
Configure the /etc/apt/sources.list file and /etc/hosts:
dchroot -c squeeze-i386 /usr/bin/vi /etc/hosts dchroot -c squeeze-i386 /usr/bin/vi /etc/apt/sources.list
Add a file in etc to describe the chroot. Put the name of the chroot in this file (i.e. squeeze-i386). This is so my modified dhcroot script can set my prompt properly.
dchroot -c squeeze-i386 /usr/bin/vi /etc/chroot
Install and configure various packages:
dchroot -c squeeze-i386 /usr/bin/aptitude update dchroot -c squeeze-i386 /usr/bin/aptitude upgrade dchroot -c squeeze-i386 /usr/bin/aptitude install pdksh sudo less locales ssh gnupg debhelper fakeroot subversion svn-buildpackage vim dchroot -c squeeze-i386 /usr/sbin/dpkg-reconfigure locale dchroot -c squeeze-i386 "/usr/bin/update-alternatives --set editor /usr/bin/vim.basic
Add my personal user:
dchroot -c squeeze-i386 /usr/sbin/useradd pronovic dchroot -c squeeze-i386 /usr/bin/passwd pronovic
Set up the sudo configuration. Run this command:
dchroot -c squeeze-i386 /usr/sbin/visudo
and add this configuration:
# User alias specification User_Alias ADMINS = pronovic User_Alias DEV = pronovic # Host alias specification # Cmnd alias specification Cmnd_Alias APT_UPDATE = /usr/bin/aptitude update Cmnd_Alias APT_UPGRADE = /usr/bin/aptitude upgrade, /usr/bin/aptitude -u upgrade Cmnd_Alias APT_INSTALL = /usr/bin/aptitude install [-_+a-zA-Z0-9]* # User privilege specification root ALL = (ALL) ALL ADMINS ALL = APT_UPDATE, APT_UPGRADE, APT_INSTALL