2004-05-03 11:59:46 +01:00
|
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2005-01-30 18:06:48 +00:00
|
|
|
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
|
2004-05-03 11:59:46 +01:00
|
|
|
<!ENTITY % general-entities SYSTEM "../general.ent">
|
|
|
|
%general-entities;
|
|
|
|
]>
|
|
|
|
<sect1 id="ch-system-chroot">
|
2005-01-30 11:27:57 +00:00
|
|
|
<title>Entering the Chroot Environment</title>
|
2004-05-03 11:59:46 +01:00
|
|
|
<?dbhtml filename="chroot.html"?>
|
|
|
|
|
2005-02-19 22:16:42 +00:00
|
|
|
<para>It is time to enter the chroot environment to begin
|
|
|
|
building and installing the final LFS system. As user
|
|
|
|
<emphasis>root</emphasis>, run the following command to enter the
|
|
|
|
realm that is, at the moment, populated with only the temporary
|
|
|
|
tools:</para>
|
2004-05-03 11:59:46 +01:00
|
|
|
|
|
|
|
<screen><userinput>chroot "$LFS" /tools/bin/env -i \
|
|
|
|
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
|
|
|
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
|
|
|
|
/tools/bin/bash --login +h</userinput></screen>
|
|
|
|
|
2005-02-19 22:16:42 +00:00
|
|
|
<para>The <parameter>-i</parameter> option given to the
|
|
|
|
<command>env</command> command will clear all variables of the chroot
|
|
|
|
environment. After that, only the <envar>HOME</envar>,
|
|
|
|
<envar>TERM</envar>, <envar>PS1</envar>, and
|
|
|
|
<envar>PATH</envar> variables are set again. The
|
|
|
|
<parameter>TERM=$TERM</parameter> construct will set the
|
|
|
|
<envar>TERM</envar> variable inside chroot to the same value as
|
|
|
|
outside chroot. This variable is needed for programs like
|
|
|
|
<command>vim</command> and <command>less</command> to operate
|
|
|
|
properly. If other variables are needed, such as
|
|
|
|
<envar>CFLAGS</envar> or <envar>CXXFLAGS</envar>, this is
|
|
|
|
a good place to set them again.</para>
|
|
|
|
|
|
|
|
<para>From this point on, there is no need to use the
|
|
|
|
<envar>LFS</envar> variable anymore, because all work will be
|
|
|
|
restricted to the LFS file system. This is because the Bash shell is
|
|
|
|
told that <filename class="directory">$LFS</filename> is now the root
|
|
|
|
(<filename class="directory">/</filename>) directory.</para>
|
|
|
|
|
|
|
|
<para>Notice that <filename class="directory">/tools/bin</filename>
|
|
|
|
comes last in the <envar>PATH</envar>. This means that a
|
|
|
|
temporary tool will not be used anymore as soon as its final version
|
|
|
|
is installed. This occurs when the shell does not <quote>remember</quote> the
|
|
|
|
locations of executed binaries—for this reason, hashing is switched
|
|
|
|
off by passing the <parameter>+h</parameter> option to <command>bash</command>.</para>
|
|
|
|
|
|
|
|
<para>It is important that all the commands throughout the remainder
|
|
|
|
of this chapter and the following chapters be run from within the
|
|
|
|
chroot environment. If you leave this environment for any reason
|
|
|
|
(rebooting for example), remember to first mount the <systemitem
|
|
|
|
class="filesystem">proc</systemitem> and <systemitem
|
|
|
|
class="filesystem">devpts</systemitem> file systems (discussed in the
|
|
|
|
previous section) and enter chroot again before continuing with the
|
|
|
|
installations.</para>
|
|
|
|
|
|
|
|
<para>Note that the bash prompt will say <quote>I have no
|
|
|
|
name!</quote> This is normal because the
|
|
|
|
<filename>/etc/passwd</filename> file has not been created yet.</para>
|
|
|
|
|
2004-05-03 11:59:46 +01:00
|
|
|
</sect1>
|
2005-02-19 22:16:42 +00:00
|
|
|
|