[6370fa6] | 1 | <sect1 id="ch06-chroot">
|
---|
[2c094d6] | 2 | <title>Entering the chroot environment</title>
|
---|
[a862ce2] | 3 | <?dbhtml filename="chroot.html" dir="chapter06"?>
|
---|
[6370fa6] | 4 |
|
---|
[2c094d6] | 5 | <para>It is time to enter the chroot environment in order to begin installing
|
---|
[44c2fd8] | 6 | the packages we need. Before you can chroot, however, you need to become
|
---|
| 7 | <emphasis>root</emphasis>, since only <emphasis>root</emphasis>
|
---|
| 8 | can execute the <userinput>chroot</userinput> command.</para>
|
---|
| 9 |
|
---|
| 10 | <para>Become <emphasis>root</emphasis> and run the following command
|
---|
[2c094d6] | 11 | to enter the chroot environment:</para>
|
---|
[44c2fd8] | 12 |
|
---|
[bc82645e] | 13 | <para><screen><userinput>chroot $LFS /stage1/bin/env -i \
|
---|
[44c2fd8] | 14 | HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
|
---|
[bc82645e] | 15 | PATH=/bin:/usr/bin:/sbin:/usr/sbin:/stage1/bin \
|
---|
| 16 | /stage1/bin/bash --login</userinput></screen>
|
---|
[44c2fd8] | 17 | </para>
|
---|
| 18 |
|
---|
[bc82645e] | 19 | <para><screen><userinput>set +h</userinput></screen></para>
|
---|
| 20 |
|
---|
[44c2fd8] | 21 | <para>The <userinput>-i</userinput> option given to the
|
---|
[2c094d6] | 22 | <userinput>env</userinput> command will clear all variables of the chroot
|
---|
[44c2fd8] | 23 | environment. After that, only the HOME, TERM, PS1 and PATH variables are
|
---|
| 24 | set again. The TERM=$TERM construct will set the TERM variable inside chroot
|
---|
| 25 | to the same value as outside chroot; this variable is needed for programs
|
---|
| 26 | like vim and less to operate properly. If you need other variables present,
|
---|
| 27 | such as CFLAGS or CXXFLAGS, this is a good place to set them again.</para>
|
---|
| 28 |
|
---|
[a07854b] | 29 | <para>From this point on there's no need to use the LFS variable anymore,
|
---|
[44c2fd8] | 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
|
---|
[7fcde5c] | 32 | the value of <filename class="directory">$LFS</filename>, which was passed to
|
---|
| 33 | the chroot command.</para>
|
---|
[44c2fd8] | 34 |
|
---|
| 35 | <para>You have to make sure all the commands in the rest of this chapter and
|
---|
[2c094d6] | 36 | in the following chapters are run from within the chroot environment.
|
---|
[44c2fd8] | 37 | If you ever leave this environment for any reason (rebooting for example),
|
---|
| 38 | you must remember to again enter chroot and mount proc (discussed later)
|
---|
| 39 | before continuing with the installations.</para>
|
---|
| 40 |
|
---|
| 41 | <para>Note that the bash prompt will say "I have no name!" This is
|
---|
| 42 | normal, as the Glibc package hasn't been installed yet.</para>
|
---|
[7e37742] | 43 |
|
---|
[6370fa6] | 44 | </sect1>
|
---|
[44c2fd8] | 45 |
|
---|