Differences between revisions 18 and 19
Revision 18 as of 2007-08-31 22:07:17
Size: 3955
Editor: JamesWestby
Comment: Minor wording changes.
Revision 19 as of 2007-12-13 16:26:10
Size: 4041
Editor: MiriamRuiz
Deletions are marked like this. Additions are marked like this.
Line 38: Line 38:
 * [http://www.debian-administration.org/articles/566 schroot: chroot for any users]


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 [http://en.wikipedia.org/wiki/Virtual_machine virtual computer] inside your system, using [http://en.wikipedia.org/wiki/User_Mode_Linux User Mode Linux], having a second computer with SID on it, or using a [http://en.wikipedia.org/wiki/Chroot 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.

["madduck"]: I suggest to introduce schroot (as a replacement of dchroot).


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 creathe 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:

  • /var/cache/apt/archives /chroot/sid/var/cache/apt/archives none bind