diff --git a/chapter02/stages.xml b/chapter02/stages.xml
index 830ec0c1f..5d08efd55 100644
--- a/chapter02/stages.xml
+++ b/chapter02/stages.xml
@@ -64,31 +64,16 @@
- The /mnt/lfs partition must be mounted.
+ You must boot the temporary system on the target machine.
- A few operations, from Changing Ownership
to
- Entering the Chroot Environment
must be done as the
- root user, with the LFS
- environment variable set for the
- rootuser.
+ A few operations, from
+ Preparing Virtual Kernel File Systems
to
+ Setting up Environment
must be done as the
+ root user.
-
- When entering chroot, the LFS environment variable must be set
- for root. The LFS
- variable is not used afterwards.
-
-
-
- The virtual file systems must be mounted. This can be done
- before or after entering chroot by changing to a host virtual terminal
- and, as root, running the
- commands in
- and
- .
-
diff --git a/chapter07/chapter07.xml b/chapter07/chapter07.xml
index 8c78f230a..35084d8b0 100644
--- a/chapter07/chapter07.xml
+++ b/chapter07/chapter07.xml
@@ -9,10 +9,10 @@
-
Entering Chroot and Building Additional Temporary Tools
+ Booting the Target System and Building Additional Temporary Tools
-
+
diff --git a/chapter07/chroot.xml b/chapter07/chroot.xml
index 6404c0625..2d0f4a4ef 100644
--- a/chapter07/chroot.xml
+++ b/chapter07/chroot.xml
@@ -6,45 +6,58 @@
]>
-
+
- Entering the Chroot Environment
+ Setting up the Environment
- Now that all the packages which are required to build the rest of the
- needed tools are on the system, it is time to enter the chroot environment to
- finish installing the remaining temporary tools. This environment will be in
- use also for installing the final system. As user root, run the following command to enter the
- environment that is, at the moment, populated with only the temporary
- tools:
+ The standard I/O streams of the initial shell process is connected
+ with /dev/console. However, the testsuite of some
+ packages may expect the standard I/O streams to be connected with a
+ real
TTY device node. Spawn a new shell process on the
+ TTY device with agetty:
-chroot "$LFS" /usr/bin/env -i \
+agetty -n -l /bin/bash tty0
+
+ If you are working via a serial console, replace
+ tty0 with the name of the serial console
+ device node, for example ttyS0.
+
+ The command above spawns a new shell process on the TTY device
+ specified in the command, and the initial shell process will run in
+ background as an init process with very limited functions. The new shell
+ process will output:
+
+bash: cannot set terminal process group (-1): Inappropriate ioctl for device
+bash: no job control in this shell
+
+ This is normal because the shell is not assigned with a
+ controlling terminal yet. Now set up controlling terminal and
+ environment variables:
+
+exec setsid -c /usr/bin/env -i \
HOME=/root \
TERM="$TERM" \
- PS1='(lfs chroot) \u:\w\$ ' \
+ PS1='(lfs) \u:\w\$ ' \
PATH=/usr/bin:/usr/sbin \
/bin/bash --login
+ The command replace the current shell process with a new shell
+ process, with controlling terminal set up.
+
The -i option given to the env
- command will clear all variables of the chroot environment. After that, only
+ command will clear all variables of the 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
+ variable to the default value specified by agetty. This variable is
needed for programs like vim and less
to operate properly. If other variables are desired, such as
CFLAGS or CXXFLAGS, this is a good place to set
them again.
- From this point on, there is no need to use the
- LFS variable anymore because all work will be restricted
- to the LFS file system. This is because the Bash shell is told that
- $LFS is now the root
- (/) directory.
-
Notice that /tools/bin is not
in the PATH. This means that the cross toolchain will no longer be
- used in the chroot environment.
+ used on the target machine.
Note that the bash prompt will say
I have no name! This is normal because the
@@ -52,12 +65,12 @@
It is important that all the commands throughout the remainder of this
- chapter and the following chapters are run from within the chroot
- environment. If you leave this environment for any reason (rebooting for
+ chapter and the following chapters are run from within the environment
+ we've set. If you leave this environment for any reason (rebooting for
example), ensure that the virtual kernel filesystems are mounted as
- explained in and and enter chroot again before continuing
- with the installation.
+ explained in and
+ and set up the environment again before
+ continuing with the installation.
diff --git a/chapter07/introduction.xml b/chapter07/introduction.xml
index 2b0030d7b..5f81e4fa8 100644
--- a/chapter07/introduction.xml
+++ b/chapter07/introduction.xml
@@ -12,21 +12,21 @@
This chapter shows how to build the last missing bits of the temporary
system: the tools needed by the build machinery of various packages. Now
- that all circular dependencies have been resolved, a chroot
- environment, completely isolated from the host operating system (except for
- the running kernel), can be used for the build.
+ that all circular dependencies have been resolved and the temporary system
+ is already bootable, we can boot it on the target machine and it would be
+ completely isolated from the host operating system. Then we can continue
+ to build on the target machine.
- For proper operation of the isolated environment, some communication
+ For proper operation of the temporary system, some communication
with the running kernel must be established. This is done through the
so-called Virtual Kernel File Systems, which must be
- mounted when entering the chroot environment. You may want to check
- that they are mounted by issuing findmnt.
+ mounted as soon as possible after boot. You may want to check
+ that they are mounted by issuing mount.
- Until , the commands must be
- run as root, with the
- LFS variable set. After entering chroot, all commands
- are run as root, fortunately without access to the OS of the computer
- you built LFS on. Be careful anyway, as it is easy to destroy the whole
- LFS system with badly formed commands.
+ All commands in this and following chapters are run as root on the
+ target system, fortunately without access to the host system.
+ Be careful anyway, as if the storage devices of your target system already
+ contain some important data, it's possible to destroy them with badly
+ formed commands.
diff --git a/chapter07/kernfs.xml b/chapter07/kernfs.xml
index f34155d7b..1259006d5 100644
--- a/chapter07/kernfs.xml
+++ b/chapter07/kernfs.xml
@@ -22,58 +22,22 @@
Begin by creating directories onto which the file systems will be
mounted:
-mkdir -pv $LFS/{dev,proc,sys,run}
-
-
- Creating Initial Device Nodes
-
- When the kernel boots the system, it requires the presence of a few
- device nodes, in particular the console and null devices. The device nodes must be
- created on the hard disk so that they are available before the kernel
- populates /dev), and
- additionally when Linux is started with
- init=/bin/bash. Create the devices by running the
- following commands:
-
-mknod -m 600 $LFS/dev/console c 5 1
-mknod -m 666 $LFS/dev/null c 1 3
-
-
-
-
- Mounting and Populating /dev
-
- The recommended method of populating the /dev directory with devices is to mount a
- virtual filesystem (such as tmpfs) on the /dev directory, and allow the devices to be
- created dynamically on that virtual filesystem as they are detected or
- accessed. Device creation is generally done during the boot process
- by Udev. Since this new system does not yet have Udev and has not yet
- been booted, it is necessary to mount and populate /dev manually. This is accomplished by bind
- mounting the host system's /dev
- directory. A bind mount is a special type of mount that allows you to
- create a mirror of a directory or mount point to some other location. Use
- the following command to achieve this:
-
-mount -v --bind /dev $LFS/dev
-
-
+mkdir -pv /{proc,sys,run}
Mounting Virtual Kernel File Systems
- Now mount the remaining virtual kernel filesystems:
+ The kernel has already mounted
+ devtmpfs.
+ Mount the remaining virtual kernel filesystems:
+
+mkdir -pv /dev/{pts,shm}
+mount -vt devpts /dev/pts /dev/pts -o gid=5,mode=620
+mount -vt proc proc /proc
+mount -vt sysfs sysfs /sys
+mount -vt tmpfs tmpfs /run
+mount -vt tmpfs tmpfs /dev/shm
-mount -v --bind /dev/pts $LFS/dev/pts
-mount -vt proc proc $LFS/proc
-mount -vt sysfs sysfs $LFS/sys
-mount -vt tmpfs tmpfs $LFS/run
-
- In some host systems, /dev/shm is a
- symbolic link to /run/shm.
- The /run tmpfs was mounted above so in this case only a
- directory needs to be created.
-if [ -h $LFS/dev/shm ]; then
- mkdir -pv $LFS/$(readlink $LFS/dev/shm)
-fi
+
+
+
+ Adjusting devtmpfs
+
+ Now proc filesystem
+ is mounted, we can replace the device nodes for standard I/O streams
+ with symlinks to pseudo files in
+ /proc/self/fd (which are symlinks
+ to the files connected to the standard I/O streams for the current
+ process). This is necessary for I/O redirection in the building system
+ of some packages to function properly:
+
+ln -sfv /proc/self/fd/0 /dev/stdin
+ln -sfv /proc/self/fd/1 /dev/stdout
+ln -sfv /proc/self/fd/2 /dev/stderr