[7152faa] | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
[fcc02767] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
| 8 | <sect1 id="ch-tools-chroot">
|
---|
| 9 | <?dbhtml filename="chroot.html"?>
|
---|
| 10 |
|
---|
| 11 | <title>Entering the Chroot Environment</title>
|
---|
| 12 |
|
---|
[387a32af] | 13 | <para>Now that all the packages which are required to build the rest of the
|
---|
[ebecd08] | 14 | needed tools are on the system, it is time to enter the chroot environment and
|
---|
| 15 | finish installing the temporary tools. This environment will also be
|
---|
| 16 | used to install the final system. As user <systemitem
|
---|
[fcc02767] | 17 | class="username">root</systemitem>, run the following command to enter the
|
---|
[ebecd08] | 18 | environment that is, at the moment, populated with nothing but temporary
|
---|
[387a32af] | 19 | tools:</para>
|
---|
[fcc02767] | 20 |
|
---|
[387a32af] | 21 | <screen role="nodump"><userinput>chroot "$LFS" /usr/bin/env -i \
|
---|
[fcc02767] | 22 | HOME=/root \
|
---|
| 23 | TERM="$TERM" \
|
---|
| 24 | PS1='(lfs chroot) \u:\w\$ ' \
|
---|
[d7a9421] | 25 | PATH=/usr/bin:/usr/sbin \
|
---|
[95ebbb4] | 26 | MAKEFLAGS="-j<replaceable>$(nproc)</replaceable>" \
|
---|
| 27 | TESTSUITEFLAGS="-j<replaceable>$(nproc)</replaceable>" \
|
---|
[490dc153] | 28 | /bin/bash --login</userinput></screen>
|
---|
[fcc02767] | 29 |
|
---|
[95ebbb4] | 30 | <para>
|
---|
[798e18b] | 31 | If you don't want to use all available logical cores, replace
|
---|
| 32 | <replaceable>$(nproc)</replaceable> with the number of logical cores you
|
---|
| 33 | want to use for building packages in this chapter and the following
|
---|
| 34 | chapters. The test suites of some packages (notably Autoconf, Libtool,
|
---|
| 35 | and Tar) in &ch-final; are not affected by <envar>MAKEFLAGS</envar>, they
|
---|
| 36 | use a <envar>TESTSUITEFLAGS</envar> environment variable instead. We
|
---|
[f16cc36] | 37 | set that here as well for running these test suites with multiple cores.
|
---|
[95ebbb4] | 38 | </para>
|
---|
| 39 |
|
---|
[fcc02767] | 40 | <para>The <parameter>-i</parameter> option given to the <command>env</command>
|
---|
[ebecd08] | 41 | command will clear all the variables in the chroot environment. After that, only
|
---|
[fcc02767] | 42 | the <envar>HOME</envar>, <envar>TERM</envar>, <envar>PS1</envar>, and
|
---|
| 43 | <envar>PATH</envar> variables are set again. The
|
---|
[ebecd08] | 44 | <parameter>TERM=$TERM</parameter> construct sets the <envar>TERM</envar>
|
---|
[fcc02767] | 45 | variable inside chroot to the same value as outside chroot. This variable is
|
---|
[ebecd08] | 46 | needed so programs like <command>vim</command> and <command>less</command>
|
---|
| 47 | can operate properly. If other variables are desired, such as
|
---|
[fcc02767] | 48 | <envar>CFLAGS</envar> or <envar>CXXFLAGS</envar>, this is a good place to set
|
---|
[ebecd08] | 49 | them.</para>
|
---|
[fcc02767] | 50 |
|
---|
| 51 | <para>From this point on, there is no need to use the
|
---|
[ebecd08] | 52 | <envar>LFS</envar> variable any more because all work will be restricted
|
---|
[f714a8f] | 53 | to the LFS file system; the <command>chroot</command> command runs the
|
---|
| 54 | Bash shell with the root
|
---|
| 55 | (<filename class="directory">/</filename>) directory set to
|
---|
| 56 | <filename class='directory'>$LFS</filename>.</para>
|
---|
[fcc02767] | 57 |
|
---|
| 58 | <para>Notice that <filename class="directory">/tools/bin</filename> is not
|
---|
[9174a66] | 59 | in the <envar>PATH</envar>. This means that the cross toolchain will no longer be
|
---|
[ebecd08] | 60 | used.</para>
|
---|
[fcc02767] | 61 |
|
---|
[798e18b] | 62 | <para>Also note that the <command>bash</command> prompt will say
|
---|
[fcc02767] | 63 | <computeroutput>I have no name!</computeroutput> This is normal because the
|
---|
| 64 | <filename>/etc/passwd</filename> file has not been created yet.</para>
|
---|
| 65 |
|
---|
| 66 | <note>
|
---|
| 67 | <para>It is important that all the commands throughout the remainder of this
|
---|
| 68 | chapter and the following chapters are run from within the chroot
|
---|
| 69 | environment. If you leave this environment for any reason (rebooting for
|
---|
| 70 | example), ensure that the virtual kernel filesystems are mounted as
|
---|
[bfab1b2] | 71 | explained in <xref linkend="ch-tools-bindmount"/> and <xref
|
---|
| 72 | linkend="ch-tools-kernfsmount"/> and enter chroot again before continuing
|
---|
[fcc02767] | 73 | with the installation.</para>
|
---|
| 74 | </note>
|
---|
| 75 |
|
---|
| 76 | </sect1>
|
---|