[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 |
|
---|
| 10 | <para>It is time to enter the chroot environment in order to begin building
|
---|
| 11 | and installing your final LFS system. Still as <emphasis>root</emphasis> run
|
---|
| 12 | the following command to enter the small world that is, at the moment,
|
---|
| 13 | populated with only the temporary tools:</para>
|
---|
| 14 |
|
---|
| 15 | <screen><userinput>chroot "$LFS" /tools/bin/env -i \
|
---|
| 16 | HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
|
---|
| 17 | PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
|
---|
| 18 | /tools/bin/bash --login +h</userinput></screen>
|
---|
| 19 |
|
---|
[3c928f1] | 20 | <para>The <parameter>-i</parameter> option given to the
|
---|
[673b0d8] | 21 | <command>env</command> command will clear all variables of the chroot
|
---|
| 22 | environment. After that, only the HOME, TERM, PS1 and PATH variables are
|
---|
[3c928f1] | 23 | set again. The <parameter>TERM=$TERM</parameter> construct will set the TERM variable inside chroot
|
---|
[673b0d8] | 24 | to the same value as outside chroot; this variable is needed for programs
|
---|
| 25 | like <command>vim</command> and <command>less</command> to operate
|
---|
| 26 | properly. If you need other variables present, such as CFLAGS or CXXFLAGS,
|
---|
| 27 | this is a good place to set them again.</para>
|
---|
| 28 |
|
---|
| 29 | <para>From this point on there's no need to use the LFS variable anymore,
|
---|
| 30 | because everything you do will be restricted to the LFS file system -- since
|
---|
| 31 | what the shell thinks is <filename class="directory">/</filename> is actually
|
---|
| 32 | the value of <filename class="directory">$LFS</filename>, which was passed to
|
---|
| 33 | the chroot command.</para>
|
---|
| 34 |
|
---|
| 35 | <para>Notice that <filename class="directory">/tools/bin</filename> comes
|
---|
| 36 | last in the PATH. This means that a temporary tool will not be used any more
|
---|
| 37 | as soon as its final version is installed. Well, at least when the shell
|
---|
| 38 | doesn't remember the locations of executed binaries -- for this reason hashing
|
---|
[3c928f1] | 39 | is switched off by passing the <parameter>+h</parameter> option to
|
---|
[673b0d8] | 40 | <command>bash</command>.</para>
|
---|
| 41 |
|
---|
| 42 | <para>You have to make sure all the commands in the rest of this chapter and
|
---|
| 43 | in the following chapters are run from within the chroot environment.
|
---|
| 44 | If you ever leave this environment for any reason (rebooting for example),
|
---|
[3c928f1] | 45 | you must remember to first mount the <systemitem class="filesystem">proc</systemitem>
|
---|
| 46 | and <systemitem class="filesystem">devpts</systemitem> file systems (discussed
|
---|
[673b0d8] | 47 | in the previous section) <emphasis>and</emphasis> enter chroot again before
|
---|
| 48 | continuing with the installations.</para>
|
---|
| 49 |
|
---|
[3c928f1] | 50 | <para>Note that the <command>bash</command> prompt will say
|
---|
| 51 | <computeroutput>I have no name!</computeroutput> This is
|
---|
[673b0d8] | 52 | normal, as the <filename>/etc/passwd</filename> file has not been created yet.
|
---|
| 53 | </para>
|
---|
| 54 |
|
---|
| 55 | </sect1>
|
---|