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