Chroot/zh-cn

Chroot (Change root) is a Unix system utility used to change the apparent root directory to create a new environment logically separate from the main system's root directory. This new environment is known as a "chroot jail." A user operating inside the jail cannot see or access files outside of the environment they have been locked into.

任何Chroot之后的操作都是为了在当前环境中创建一个虚拟Linux系统，来测试系统及软件的兼容性. Chroot一般被视为一个轻量级的虚拟环境，因为它可以不依赖虚拟化环境来运行.

Setting up the environment
当你创建一个新的环境时，首先要做的就是创建一个你将chroot进入的目录，比如 :

如果你想挂载一个已经装好系统的分区，你可以使用以下命令. 一定要更换 字符串，在下面的驱动器和现有安装的分区中，例如：

如果你有一个已经安装在根目录下某个子目录中的系统，就不需要再做上述操作.

Unpacking system files and the Portage tree (new installations)
当你已经开始安装，下一步就是下载stage3和portage包，并将它们放到要chroot的位置. 获取此操作更多信息，请看Gentoo Handbook中的Downloading the stage tarball和Unpacking the stage tarball章节.

配置
在进入chroot之前，我们挂载一些目录.

然后你还要从主系统复制一些基本配置文件，如果你使用一个已装好的系统，就不要复制.

Usage
做完这几步，你就可以通过执行下面的命令chroot进入新环境了.

创建好环境后，你就应该同步portage，更新到最新状态.

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 or press +. Doing so will return the console back to the normal environment. Do not forget to the directories that have been mounted.

Init scripts
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. The script could be added to the default runlevel and therefore set up automatically on system boot:

当你正在使用其他目录或分区，在the 部分添加必要的挂载命令，另外，如果你使用的不同目录名，修改为适当的名字即可.

另请参阅

 * Chroot Guide
 * Chrooting proxy services