Various file systems exported by the kernel are used to communicate to and from the kernel itself. These file systems are virtual in that no disk space is used for them. The content of the file systems resides in memory.
Begin by creating directories onto which the file systems will be mounted:
install -vd $HLFS/{dev,proc,sys}
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 will be created on the hard disk so that
they are available before udevd has been started, and
additionally when Linux is started with init=/bin/bash. Create the devices by
running the following commands:
mknod -m 600 $HLFS/dev/console c 5 1 mknod -m 666 $HLFS/dev/null c 1 3
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. This 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 $HLFS/dev
Now mount the remaining virtual kernel filesystems:
mount -vt devpts -o mode=620 devpts $HLFS/dev/pts mount -vt tmpfs shm $HLFS/dev/shm mount -vt proc proc $HLFS/proc mount -vt sysfs sysfs $HLFS/sys
If you are running an existing HLFS system with all of the Grsecurity options enabled, some will need to be disabled to compile the system in this chapter. If you compiled the kernel with sysctl support in Grsecurity then use these commands:
sysctl -w kernel.grsecurity.chroot_caps=0 sysctl -w kernel.grsecurity.chroot_deny_mknod=0 sysctl -w kernel.grsecurity.chroot_deny_chmod=0 sysctl -w kernel.grsecurity.chroot_deny_mount=0