Differences between revisions 2 and 24 (spanning 22 versions)
Revision 2 as of 2007-08-23 14:21:21
Size: 2749
Editor: MiriamRuiz
Comment:
Revision 24 as of 2014-02-08 13:42:59
Size: 4604
Editor: ?MichaelWeghorn
Comment: typo
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
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. 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. ## page was renamed from English/Courses/MaintainingPackages/Intro/Chroot
#language en
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: none-~
----
Line 3: Line 6:
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 a different operative system in their computers than Linux (whether it is BSD, OS X, or any others). 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. == Theory ==
Line 5: Line 8:
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 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/". 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.
Line 7: Line 10:
Afterwards, we might consider copying some of the configuration files (such as /etc/passwd, /etc/group, /etc/shadow, /etc/hosts, /etc/fstab y /etc/resolv.conf) from our main system to the chroot environment, so that files have they match. You can enter the chroot just by doing "chroot /chroot/sid" as root. You might as well type "sudo /usr/sbin/chroot /chroot/sid login $USER" or any similar sequence of commands to automatize it. 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 [[WikiPedia:Virtual_machine|virtual computer]] inside your system, using [[WikiPedia:User_Mode_Linux|user mode Linux]], having a second computer with SID on it, or using a [[WikiPedia: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.

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 [[DebianPkg:schroot|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.
Line 11: Line 24:
/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
 * /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
Line 20: Line 33:
/tmp /chroot/sid/tmp none bind  * /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
Line 23: Line 40:
 * WikiPedia:Debian
 * WikiPedia:Chroot
Line 24: Line 43:
 * [[http://www.debian-administration.org/articles/566|schroot: chroot for any users]]


----

Translation(s): none


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:

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