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:
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 aninit 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) \u:\w\$ ' \ PATH=/usr/bin:/usr/sbin \ /bin/bash --login +h
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 environment. After that, only the HOME
, TERM
, PS1
, and PATH
variables are
set again. The TERM=$TERM
construct will set the TERM
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.
Notice that /tools/bin
is not in the
PATH
. This means that the cross toolchain
will no longer be used in the building environment. This occurs when
the shell does not “remember” the locations of executed
binaries—for this reason, hashing is switched off by passing
the +h
option to bash.
Note that the bash
prompt will say I have no name!
This is normal because the /etc/passwd
file has not been created yet.
It is important that all the commands throughout the remainder of this 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 Section 7.2.1, “Mounting Virtual Kernel File Systems” and Section 7.2.2, “Adjusting devtmpfs and Setting Controlling Terminal” and set up the environment again before continuing with the installation.