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 ...)
Building a "chroot" is very easy in Debian.
You will need:
- Install the required packages
aptitude install binutils debootstrap
- Choose a location
mkdir -p /var/chroot/etch
- Build the chroot
debootstrap --arch i386 etch /var/chroot/etch
- Recovery of an "image", decompression and installation of required packages
- To enter:
In general, it is necessary to create/edit key configuration points
Configuring a chroot is relatively static and very specific, it may be possible to dispense with the command "top-level" and directly edit files.
- Users defined in the chroot
- Settings network settings
- Mounts filesystems
Mounting pseudo filesystems
- Check the chrooted system the presence of /proc if the chroot is not likely to be fully operational. A priori, since version debootstrap Debian/Etch integrates natively mount /proc and /sys
proc on /proc type proc (rw) sysfs on /sys sysfs kind (rw)
It is also advisable to do a "bind" /dev/pts. This prevents error messages like Must be connected to a terminal or Can not access '/dev/pts/0': No such file or directory of this type with using the control screen.
In this case, the primary system, run the command:
mount --bind /dev/pts /var/chroot/etch/dev/pts
Generally the file /etc/fstab might look like this:
# cat /etc/fstab | grep chroot /dev /var/chroot/etch/dev auto bind 0 0 /dev/pts /var/chroot/etch/dev/pts auto bind 0 0 /proc /var/chroot/etch/proc auto bind 0 0
Therefore mount on the primary system would be:
# mount | grep chroot /dev on /var/chroot/etch/dev -type none (rw, bind) /dev/pts on /var/chroot/etch/dev/pts kind none (rw, bind) /proc on /var/chroot/etch/proc type none (rw, bind)
Adding / removing packages
- Eliminate unnecessary packages (all depends on the purpose of the chroot)
apt-get install deborphan
- And for example
apt-get remove --purge telnet manpages pppconfig ipchains ...
Complementary list svgalibg1 whiptail
- Add a little comfort
apt-get install emacs21 local mc
Common examples of chroot usage:
Recompiling application in a context other than the machine that hosts the chroot (backport, cross-compiling, ...)
- Update service production by tilting the old service (host machine) to the new (installed in the chroot)
- Securing a service "chrooted" from the host machine (and vice versa)
ToDo - Clean up from French translation.