Theory

Most of us have our system configured with packages from different sources. Some of you might not even be using Debian in your main system, and those who do, might not be using SID. SID (which stands for Still In Development), also known as Debian Unstable, is the name used for the repositories of Debian in which the development is really done. There are also other repositories (stable, testing and experimental), but we'll talk about that later.

Even though new packages can be developed and compiled in any Debian system or derivative, if you have the intention of getting them into Debian sometime you'll have to develop them under SID. This does not mean you must use SID in your main system, there are other alternatives, like using a SID installed in a virtual computer inside your system, using user mode Linux, having a second computer with SID on it, or using a chroot.

Of course, you might want to install a whole Debian system in a virtual computer. That will probably be the best option for those using an operative system in their computer other than Linux (whether it is BSD, OS X, or any other). If you're already using Debian or Ubuntu, or even if you're using some other Linux distribution, you might consider working inside a chroot environment instead of using a virtual computer, as there is less overhead with this method.

If you're using Debian (or any Debian derivative) as your host computer, you can also consider using schroot as a normal user instead of chroot (which would need you to be root). schroot is a program to allow users to execute commands or interactive shells in different chroots. All you have to do is to install the schroot package, configure it by modifying the file /etc/schroot/schroot.conf, and use it to enter your chroot environment, typing a comand in the form of schroot -c <chroot_environment> -p <command and parameters>.

Exercises

The quickest and easiest way to create a chroot environment if you're using Debian or any derivative in your system is through the commands debootstrap or cdebootstrap. You should type something like “debootstrap (or cdebootstrap) SUITE TARGET [MIRROR]”, where SUITE is any of those in Debian (sid, testing, stable, oldstable), TARGET points to the directory where we want to create the chroot environment, and MIRROR is the URL for repository from which we'll obtain the packages. It'll be something like: "mkdir -p /chroot/sid && debootstrap sid /chroot/sid http://ftp.de.debian.org/debian/".

Afterwards, we might consider copying some of the configuration files (such as /etc/passwd, /etc/group, /etc/shadow, /etc/hosts, /etc/fstab and /etc/resolv.conf) from our main system to the chroot environment, so that files they have match. You can enter the chroot just by doing "chroot /chroot/sid" as root. You can type "sudo /usr/sbin/chroot /chroot/sid login $USER" or any similar sequence of commands to automate it.

You can link some of the directories in your main system to some others inside your chroot, with "mount --bind olddir newdir", or adding in your /etc/fstab something like:

/home /chroot/sid/home none bind

/dev /chroot/sid/dev none bind

devpts /chroot/sid/dev/pts devpts defaults 0 0

sys /chroot/sid/sys sysfs defaults 0 0

proc /chroot/sid/proc proc defaults 0 0

usb /chroot/sid/proc/bus/usb usbfs defaults 0 0

You can also do more fancy stuff, like starting a new X server inside the chroot, or add new virtual terminals that start inside the chroot system. If you're using Debian in your main system, you might also be able to easily open X windows from inside the chroot into your main X server, just by sharing the same /tmp directories:

/tmp /chroot/sid/tmp none bind

Another interesting thing that could be done is to share the cache of the Debian packages downloaded by APT between our chroot environment and our main system, so that common packages only need to be downloaded once, and also they don't occupy double the space on the hard disk: