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