It is time to enter the chroot environment in order to begin building and installing your final LFS system. Still as root run the following command to enter the small world that is, at the moment, populated with only the temporary tools:
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
The -i option given to the env command will clear all variables of the chroot 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.
From this point on there's no need to use the LFS variable anymore, because everything you do will be restricted to the LFS file system -- since what the shell thinks is / is actually the value of $LFS, which was passed to the chroot command.
Notice that /tools/bin comes last in the PATH. This means that a temporary tool will not be used any more as soon as its final version is installed. Well, at least when the shell doesn't remember the locations of executed binaries -- for this reason hashing is switched off by passing the +h option to bash.
You have to make sure all the commands in the rest of this chapter and in the following chapters are run from within the chroot environment. If you ever leave this environment for any reason (rebooting for example), you must remember to first mount the proc and devpts file systems (discussed in the previous section) and enter chroot again before continuing with the installations.
Note that the bash prompt will say “I have no name!” This is normal, as the /etc/passwd file has not been created yet.