2001-01-24 00:31:17 +00:00
|
|
|
<sect1 id="ch06-chroot">
|
2002-09-28 22:08:29 +01:00
|
|
|
<title>Entering the chroot environment</title>
|
2001-09-26 06:07:07 +01:00
|
|
|
<?dbhtml filename="chroot.html" dir="chapter06"?>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2002-09-28 22:08:29 +01:00
|
|
|
<para>It is time to enter the chroot environment in order to begin installing
|
2002-09-08 22:54:14 +01:00
|
|
|
the packages we need. Before you can chroot, however, you need to become
|
|
|
|
<emphasis>root</emphasis>, since only <emphasis>root</emphasis>
|
|
|
|
can execute the <userinput>chroot</userinput> command.</para>
|
|
|
|
|
2003-10-02 07:03:29 +01:00
|
|
|
<para>Just like earlier, ensure the LFS environment variable is set up properly
|
2003-10-05 09:56:39 +01:00
|
|
|
by running <userinput>echo $LFS</userinput> and ensuring it shows the path to
|
|
|
|
your LFS partition's mount point, which is
|
2003-10-02 07:03:29 +01:00
|
|
|
<filename class="directory">/mnt/lfs</filename> if you followed our
|
|
|
|
example.</para>
|
|
|
|
|
2002-09-08 22:54:14 +01:00
|
|
|
<para>Become <emphasis>root</emphasis> and run the following command
|
2002-09-28 22:08:29 +01:00
|
|
|
to enter the chroot environment:</para>
|
2002-09-08 22:54:14 +01:00
|
|
|
|
2003-10-10 00:22:07 +01:00
|
|
|
<screen><userinput>chroot $LFS /tools/bin/env -i \
|
2002-09-08 22:54:14 +01:00
|
|
|
HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
|
2003-09-02 23:03:51 +01:00
|
|
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
|
2003-10-10 00:22:07 +01:00
|
|
|
/tools/bin/bash --login</userinput></screen>
|
2002-09-08 22:54:14 +01:00
|
|
|
|
2003-10-10 00:22:07 +01:00
|
|
|
<screen><userinput>set +h</userinput></screen>
|
2003-05-02 19:20:20 +01:00
|
|
|
|
2002-09-08 22:54:14 +01:00
|
|
|
<para>The <userinput>-i</userinput> option given to the
|
2002-09-28 22:08:29 +01:00
|
|
|
<userinput>env</userinput> command will clear all variables of the chroot
|
2002-09-08 22:54:14 +01:00
|
|
|
environment. After that, only the HOME, TERM, PS1 and PATH variables are
|
|
|
|
set again. The TERM=$TERM construct will set the TERM variable inside chroot
|
|
|
|
to the same value as outside chroot; this variable is needed for programs
|
|
|
|
like vim and less to operate properly. If you need other variables present,
|
|
|
|
such as CFLAGS or CXXFLAGS, this is a good place to set them again.</para>
|
|
|
|
|
2003-09-17 19:06:39 +01:00
|
|
|
<para>Also note the use of the set +h directive. This tells bash to not use
|
2003-09-26 05:11:08 +01:00
|
|
|
its internal path hashing. Without this directive, bash will remember paths
|
2003-09-17 19:06:39 +01:00
|
|
|
to binaries. Since as we go thru chapter 6, we want to use our newly compiled
|
|
|
|
binaries as soon as they are installed, we turn off this function.</para>
|
|
|
|
|
2002-12-03 20:37:18 +00:00
|
|
|
<para>From this point on there's no need to use the LFS variable anymore,
|
2002-09-08 22:54:14 +01:00
|
|
|
because everything you do will be restricted to the LFS file system -- since
|
|
|
|
what the shell thinks is <filename class="directory">/</filename> is actually
|
2002-12-03 20:36:44 +00:00
|
|
|
the value of <filename class="directory">$LFS</filename>, which was passed to
|
|
|
|
the chroot command.</para>
|
2002-09-08 22:54:14 +01:00
|
|
|
|
|
|
|
<para>You have to make sure all the commands in the rest of this chapter and
|
2002-09-28 22:08:29 +01:00
|
|
|
in the following chapters are run from within the chroot environment.
|
2002-09-08 22:54:14 +01:00
|
|
|
If you ever leave this environment for any reason (rebooting for example),
|
2003-09-22 19:52:57 +01:00
|
|
|
you must remember to again enter chroot and mount the proc and devpts
|
|
|
|
filesystems (discussed later) before continuing with the installations.</para>
|
2002-09-08 22:54:14 +01:00
|
|
|
|
|
|
|
<para>Note that the bash prompt will say "I have no name!" This is
|
2003-09-11 21:27:27 +01:00
|
|
|
normal, as the <filename>/etc/passwd</filename> file has not been
|
|
|
|
created yet.</para>
|
2001-01-27 01:44:15 +00:00
|
|
|
|
2001-01-24 00:31:17 +00:00
|
|
|
</sect1>
|
2002-09-08 22:54:14 +01:00
|
|
|
|