|
@@ -8,12 +8,15 @@
|
|
<sect1 id="ch-system-chroot">
|
|
<sect1 id="ch-system-chroot">
|
|
<?dbhtml filename="chroot.html"?>
|
|
<?dbhtml filename="chroot.html"?>
|
|
|
|
|
|
- <title>Entering the Chroot Environment</title>
|
|
|
|
|
|
+ <title>进入 Chroot 环境</title>
|
|
|
|
|
|
- <para>It is time to enter the chroot environment to begin building and
|
|
|
|
|
|
+ <!--para>It is time to enter the chroot environment to begin building and
|
|
installing the final LFS system. As user <systemitem
|
|
installing the final LFS system. As user <systemitem
|
|
class="username">root</systemitem>, run the following command to enter the
|
|
class="username">root</systemitem>, run the following command to enter the
|
|
- realm that is, at the moment, populated with only the temporary tools:</para>
|
|
|
|
|
|
+ realm that is, at the moment, populated with only the temporary tools:</para-->
|
|
|
|
+ <para>现在到了进入 chroot 环境,并开始构建和安装最终的 LFS 系统的时候。
|
|
|
|
+ 以 <systemitem class="username">root</systemitem> 身份。
|
|
|
|
+ 执行下列命令,进入这个目前只包含临时工具的空间:</para>
|
|
|
|
|
|
<screen role="nodump"><userinput>chroot "$LFS" /tools/bin/env -i \
|
|
<screen role="nodump"><userinput>chroot "$LFS" /tools/bin/env -i \
|
|
HOME=/root \
|
|
HOME=/root \
|
|
@@ -22,7 +25,7 @@
|
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
|
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
|
|
/tools/bin/bash --login +h</userinput></screen>
|
|
/tools/bin/bash --login +h</userinput></screen>
|
|
|
|
|
|
- <para>The <parameter>-i</parameter> option given to the <command>env</command>
|
|
|
|
|
|
+ <!--para>The <parameter>-i</parameter> option given to the <command>env</command>
|
|
command will clear all variables of the chroot environment. After that, only
|
|
command will clear all variables of the chroot environment. After that, only
|
|
the <envar>HOME</envar>, <envar>TERM</envar>, <envar>PS1</envar>, and
|
|
the <envar>HOME</envar>, <envar>TERM</envar>, <envar>PS1</envar>, and
|
|
<envar>PATH</envar> variables are set again. The
|
|
<envar>PATH</envar> variables are set again. The
|
|
@@ -31,33 +34,63 @@
|
|
needed for programs like <command>vim</command> and <command>less</command>
|
|
needed for programs like <command>vim</command> and <command>less</command>
|
|
to operate properly. If other variables are needed, such as
|
|
to operate properly. If other variables are needed, such as
|
|
<envar>CFLAGS</envar> or <envar>CXXFLAGS</envar>, this is a good place to set
|
|
<envar>CFLAGS</envar> or <envar>CXXFLAGS</envar>, this is a good place to set
|
|
- them again.</para>
|
|
|
|
|
|
+ them again.</para-->
|
|
|
|
+ <para>传递给 <command>env</command> 的 <parameter>-i</parameter>
|
|
|
|
+ 参数会清除 chroot 环境中的所有环境变量。
|
|
|
|
+ 随后,只重新设定 <envar>HOME</envar>、<envar>TERM</envar>、
|
|
|
|
+ <envar>PS1</envar> 和 <envar>PATH</envar> 变量。
|
|
|
|
+ 参数 <parameter>TERM=$TERM</parameter> 将 chroot 环境中的
|
|
|
|
+ <envar>TERM</envar> 变量设为和 chroot 环境外相同的值,
|
|
|
|
+ 许多程序需要这个变量才能正常工作,例如 <command>vim</command>
|
|
|
|
+ 和 <command>less</command>。如果需要设定其他变量,例如
|
|
|
|
+ <envar>CFLAGS</envar> 或 <envar>CXXFLAGS</envar>,
|
|
|
|
+ 在这里顺便设定比较合适。</para>
|
|
|
|
|
|
- <para>From this point on, there is no need to use the
|
|
|
|
|
|
+
|
|
|
|
+ <!--para>From this point on, there is no need to use the
|
|
<envar>LFS</envar> variable anymore, because all work will be restricted
|
|
<envar>LFS</envar> variable anymore, because all work will be restricted
|
|
to the LFS file system. This is because the Bash shell is told that
|
|
to the LFS file system. This is because the Bash shell is told that
|
|
<filename class="directory">$LFS</filename> is now the root
|
|
<filename class="directory">$LFS</filename> is now the root
|
|
- (<filename class="directory">/</filename>) directory.</para>
|
|
|
|
|
|
+ (<filename class="directory">/</filename>) directory.</para-->
|
|
|
|
+ <para>从现在开始,就不再需要使用 <envar>LFS</envar> 环境变量,
|
|
|
|
+ 因为所有工作都被局限在 LFS 文件系统内。这是由于 Bash 被告知
|
|
|
|
+ <filename class="directory">$LFS</filename> 现在是根目录
|
|
|
|
+ (<filename class="directory">/</filename>)。</para>
|
|
|
|
|
|
- <para>Notice that <filename class="directory">/tools/bin</filename> comes last
|
|
|
|
|
|
+ <!--para>Notice that <filename class="directory">/tools/bin</filename> comes last
|
|
in the <envar>PATH</envar>. This means that a temporary tool will no longer be
|
|
in the <envar>PATH</envar>. This means that a temporary tool will no longer be
|
|
used once its final version is installed. This occurs when the shell does not
|
|
used once its final version is installed. This occurs when the shell does not
|
|
<quote>remember</quote> the locations of executed binaries—for this
|
|
<quote>remember</quote> the locations of executed binaries—for this
|
|
reason, hashing is switched off by passing the <parameter>+h</parameter> option
|
|
reason, hashing is switched off by passing the <parameter>+h</parameter> option
|
|
- to <command>bash</command>.</para>
|
|
|
|
|
|
+ to <command>bash</command>.</para-->
|
|
|
|
+ <para>注意到 <filename class="directory">/tools/bin</filename>
|
|
|
|
+ 处于 <envar>PATH</envar> 的末尾,
|
|
|
|
+ 这意味着一旦安装了某个工具的最终版本,就不再使用对应的临时工具。
|
|
|
|
+ 这还需要保证 shell 不 <quote>记忆</quote> 执行过的程序的位置
|
|
|
|
+ —— 因此需要传递 <parameter>+h</parameter> 参数给
|
|
|
|
+ <command>bash</command> 以关闭散列功能。</para>
|
|
|
|
|
|
- <para>Note that the <command>bash</command> prompt will say
|
|
|
|
|
|
+ <!--para>Note that the <command>bash</command> prompt will say
|
|
<computeroutput>I have no name!</computeroutput> This is normal because the
|
|
<computeroutput>I have no name!</computeroutput> This is normal because the
|
|
- <filename>/etc/passwd</filename> file has not been created yet.</para>
|
|
|
|
|
|
+ <filename>/etc/passwd</filename> file has not been created yet.</para-->
|
|
|
|
+ <para>注意 <command>bash</command> 的提示符会包含
|
|
|
|
+ <computeroutput>I have no name!</computeroutput> 。
|
|
|
|
+ 这是正常的,因为现在还没有创建 <filename>/etc/passwd</filename> 文件。
|
|
|
|
+ </para>
|
|
|
|
|
|
<note>
|
|
<note>
|
|
- <para>It is important that all the commands throughout the remainder of this
|
|
|
|
|
|
+ <!--para>It is important that all the commands throughout the remainder of this
|
|
chapter and the following chapters are run from within the chroot
|
|
chapter and the following chapters are run from within the chroot
|
|
environment. If you leave this environment for any reason (rebooting for
|
|
environment. If you leave this environment for any reason (rebooting for
|
|
example), ensure that the virtual kernel filesystems are mounted as
|
|
example), ensure that the virtual kernel filesystems are mounted as
|
|
explained in <xref linkend="ch-system-bindmount"/> and <xref
|
|
explained in <xref linkend="ch-system-bindmount"/> and <xref
|
|
linkend="ch-system-kernfsmount"/> and enter chroot again before continuing
|
|
linkend="ch-system-kernfsmount"/> and enter chroot again before continuing
|
|
- with the installation.</para>
|
|
|
|
|
|
+ with the installation.</para-->
|
|
|
|
+ <para>本章剩余部分和后续各章中的命令都要在 chroot 环境中运行。
|
|
|
|
+ 如果您因为一些原因(如重新启动计算机)离开了该环境,
|
|
|
|
+ 必须确认虚拟内核文件系统如 <xref linkend="ch-system-bindmount"/>
|
|
|
|
+ 和 <xref linkend="ch-system-kernfsmount"/> 所述挂载好,
|
|
|
|
+ 然后重新进入 chroot 环境,才能继续安装 LFS 。</para>
|
|
</note>
|
|
</note>
|
|
|
|
|
|
</sect1>
|
|
</sect1>
|