Chroot/ru

Chroot (англ. Change Root — «изменение корневого каталога») — это системная утилита Unix, используемая для смены текущего корневого каталога с целью создания нового окружения, логически отдельного от основной системы. Это новое окружение также известно как «chroot jail» («тюрьма»). Пользователь, работающий внутри jail, не может видеть файлы вне среды, которой они ограничены, или обращаться к ним.

One of the main uses for chrooting is to create a separate Linux system on top of a the current one for the purpose of testing or software compatibility. Chroot is often seen as a lightweight alternative to virtualization because it is able to run without the overhead of a hypervisor.

Настройка окружения
When creating a new chroot setup, the first thing needed is a directory for the chroot to reside in. For example, a chroot could be created in :

To mount an existing installation from a partition the following command can be ran. Be sure to replace the  string in the example below with the drive and partition of the existing installation:

If an installation has been previously created in a sub directory of the current root file system the above steps can be skipped.

Unpacking system files and the Portage tree (new installations)
When building a new install, the next step is to download the stage3 and Portage tarballs and set them up in the chroot location. For more information on this process please see sections 5a and 5b in the Gentoo Handbook.

Настройка
Перед тем, как изменить корневой каталог, нам необходимо смонтировать несколько каталогов.

Нам также необходимо скопировать несколько основных файлов конфигурации из основной системы; не копируйте, если используете существующую установку.

Once done enter the chroot environment by executing the following commands:

When creating a new installation Portage should be synced to make sure everything is up to date.

The system is now ready; feel free to install software, mess with settings, test experimental packages and configurations without having any effect on the main system. To leave the chroot simply type exit or press +. Doing so will return the console back to the normal environment. Do not forget to umount the directories that have been mounted.

Сценарии инициализации
If setting up chroots is a task that is needed to be performed often, it is possible to speed up the mounting of the directories by using an init script:

When using a different directory or partition, add the necessary mounting commands in the  function and change  to the appropriate name.

Смотрите также

 * Gentoo x86 Chroot Setup Guide