In Debian-based distributions (eg ubuntu) you can easily create a fully-featured chroot environment for running stuff, including services. There are some good sides to that. For example, if you are messing about with repositories and dependencies, you can do that in a chrooted environment without destroying your host system. Also, you can run services in your chroot environment (and install them there). It’s almost like virtualisation (but without virtualizing
). I like to use chroot on debootstrap for testing and to chroot a few services like apache. If someone hacks into your system using eg a php bug, they won’t be able to break your host system, as they can’t break out of the chroot jail
. Well, it’s quite simple, although, you need to tweak a few stuff to run services there. Well, here goes:
aptitude install debootstrap mkdir /mnt/sys01 debootstrap --arch i386 jaunty /mnt/sys01 http://archive.ubuntu.com/ubuntu cp /etc/hosts /mnt/sys01/etc cp /etc/hostname /mnt/sys01/etc cd /mnt mount -t proc proc /mnt/sys01/proc/ mount -t sysfs sysfs /mnt/sys01/sys/ chroot sys01 locale-gen en_GB.UTF-8 aptitude update && aptitude upgrade exit
From now on, every time you type in chroot /mnt/sys01 voila! You are in the chroot environment. It’s a full thing, so aptitude has it’s own repo configured, it has it’s own installed packages, etc… Like a new system