[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
---|
| 3 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
| 6 | <sect1 id="ch-system-chroot">
|
---|
| 7 | <title>Entering the chroot environment</title>
|
---|
| 8 | <?dbhtml filename="chroot.html"?>
|
---|
| 9 |
|
---|
[ef13657] | 10 | <para>It is time to enter the chroot environment in order to begin
|
---|
| 11 | building and installing the final LFS system. As user
|
---|
| 12 | <emphasis>root</emphasis>, run the following command to enter the
|
---|
| 13 | realm that is, at the moment, populated with only the temporary
|
---|
| 14 | tools:</para>
|
---|
[673b0d8] | 15 |
|
---|
| 16 | <screen><userinput>chroot "$LFS" /tools/bin/env -i \
|
---|
| 17 | HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
|
---|
| 18 | PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
|
---|
| 19 | /tools/bin/bash --login +h</userinput></screen>
|
---|
| 20 |
|
---|
[3c928f1] | 21 | <para>The <parameter>-i</parameter> option given to the
|
---|
[673b0d8] | 22 | <command>env</command> command will clear all variables of the chroot
|
---|
[ef13657] | 23 | environment. After that, only the <emphasis>HOME</emphasis>,
|
---|
| 24 | <emphasis>TERM</emphasis>, <emphasis>PS1</emphasis>, and
|
---|
| 25 | <emphasis>PATH</emphasis> variables are set again. The
|
---|
| 26 | <parameter>TERM=$TERM</parameter> construct will set the
|
---|
| 27 | <emphasis>TERM</emphasis> variable inside chroot to the same value as
|
---|
| 28 | outside chroot. This variable is needed for programs like
|
---|
| 29 | <command>vim</command> and <command>less</command> to operate
|
---|
| 30 | properly. If other variables are needed, such as
|
---|
| 31 | <emphasis>CFLAGS</emphasis> or <emphasis>CXXFLAGS</emphasis>, this is
|
---|
| 32 | a good place to set them again.</para>
|
---|
| 33 |
|
---|
| 34 | <para>From this point on there is no need to use the
|
---|
| 35 | <emphasis>LFS</emphasis> variable anymore, because all work will be
|
---|
| 36 | restricted to the LFS file system. This is because the Bash shell is
|
---|
| 37 | told that <filename class="directory">$LFS</filename> is now the root
|
---|
| 38 | (<filename class="directory">/</filename>) directory.</para>
|
---|
| 39 |
|
---|
| 40 | <para>Notice that <filename class="directory">/tools/bin</filename> comes last in the PATH. This means that a
|
---|
| 41 | temporary tool will not be used anymore as soon as its final version
|
---|
| 42 | is installed. This occurs when the shell does not <quote>remember</quote> the
|
---|
| 43 | locations of executed binaries -- for this reason, hashing is switched
|
---|
| 44 | off by passing the +h option to bash.</para>
|
---|
| 45 |
|
---|
| 46 | <para>It is important that all the commands throughout the remainder
|
---|
| 47 | of this chapter and the following chapters are run from within the
|
---|
| 48 | chroot environment. If you leave this environment for any reason
|
---|
| 49 | (rebooting for example), remember to first mount the <systemitem
|
---|
| 50 | class="filesystem">proc</systemitem> and <systemitem
|
---|
| 51 | class="filesystem">devpts</systemitem> file systems (discussed in the
|
---|
| 52 | previous section) and enter chroot again before continuing with the
|
---|
| 53 | installations.</para>
|
---|
| 54 |
|
---|
| 55 | <para>Note that the bash prompt will say <quote>I have no
|
---|
| 56 | name!</quote> This is normal because the
|
---|
| 57 | <filename>/etc/passwd</filename> file has not been created yet.</para>
|
---|
[673b0d8] | 58 |
|
---|
| 59 | </sect1>
|
---|
[ef13657] | 60 |
|
---|