Translation(s): Deutsch - English - Fran├žais - Italiano - Espa├▒ol

chroot on Unix-like operating systems is an operation that changes the apparent root directory for the current running process and its children.(Read more ...)

Basic Installation

Building a "chroot" is very easy in Debian.

You will need:

apt-get install binutils debootstrap

mkdir -p /srv/chroot/wheezy

Either select a close network mirror manually, use one of the dns based mirrors such as where XX is your geographic country code, or use the which will do this for you automatically. The is easier to document and becoming the generally preferred method and is therefore recommended if you don't have your own fast preferred local mirror. See for documentation and details.

debootstrap --arch i386 wheezy /srv/chroot/wheezy

chroot /srv/chroot/wheezy


In general, it is necessary to create/edit key configuration points.

Create a /usr/sbin/policy-rc.d file IN THE CHROOT so that dpkg won't start daemons unless desired. This example prevents all daemons from being started in the chroot.

chroot /srv/chroot/wheezy
cat > ./usr/sbin/policy-rc.d <<EOF
exit 101
chmod a+x ./usr/sbin/policy-rc.d

The ischroot command is buggy and does not detect that it is running in a chroot (685034). Several packages depend upon ischroot for determining correct behavior in a chroot and will operate incorrectly during upgrades if it is not fixed. The easiest way to fix it is to replace ischroot with the /bin/true command.

dpkg-divert --divert /usr/bin/ischroot.debianutils --rename /usr/bin/ischroot
ln -s /bin/true /usr/bin/ischroot

Configuring a chroot is relatively static and very specific, it may be possible to dispense with the command "top-level" and directly edit files.




Mounting pseudo filesystems


proc on /proc type proc (rw)
sysfs on /sys sysfs kind (rw)


In this case, the primary system, run the command:

mount --bind /dev/pts /srv/chroot/wheezy/dev/pts

Default Configurations

Generally the file /etc/fstab might look like this:

# grep chroot /etc/fstab
/dev /srv/chroot/wheezy/dev auto bind 0 0
/dev/pts /srv/chroot/wheezy/dev/pts auto bind 0 0
/proc /srv/chroot/wheezy/proc auto bind 0 0

Therefore mount on the primary system would be:

# mount | grep chroot
/dev on /srv/chroot/wheezy/dev -type none (rw, bind)
/dev/pts on /srv/chroot/wheezy/dev/pts kind none (rw, bind)
/proc on /srv/chroot/wheezy/proc type none (rw, bind)

Adding / removing packages

apt-get install deborphan

deborphan -a

apt-get remove --purge telnet manpages pppconfig ipchains ...

Complementary list svgalibg1 whiptail

apt-get install emacs23 local mc


Common examples of chroot usage:

Advanced Usage

The schroot package provides a convenient wrapper for allowing unprivileged users to have access to one or more chroot environments. schroot handles the chroot(2) call as well as dropping privileges inside the chroot and bind mounting resources into the chroot (like home directories, /dev, /proc).

ToDo - Clean up from French translation.