8.3. Mounting Virtual Kernel File Systems

#### Cross-Compiled Linux From Scratch - Version 1.0.0rc1-MIPS64-Multilib

### Chapter 8. If You Are Going to Chroot

- Prev

  Util-linux-2.12r

- Next

  Entering the Chroot Environment

- Up.
- Home

# 8.3. Mounting Virtual Kernel File Systems

### Note

The commands in the remainder of the book should be run as the `root` user. Also, double-check that $LFS is set as `root`.

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:

    mkdir -pv $LFS/{dev,proc,sys}

Now mount the file systems:

    mount -vt proc proc $LFS/proc
    mount -vt sysfs sysfs $LFS/sys

Remember that if for any reason you stop working on the CLFS system and start again later, it is important to check that these file systems are mounted again before entering the chroot environment.

Two device nodes, /dev/console and /dev/null, are required to be present on the filesystem. These are needed by the kernel even before starting Udev early in the boot process, so we create them here:

    mknod -m 600 $LFS/dev/console c 5 1
    mknod -m 666 $LFS/dev/null c 1 3

Once the system is complete and booting, the rest of our device nodes are created by the Udev package. Since this package is not available to us right now, we must take other steps to provide device nodes under on the CLFS filesystem. We will use the “bind” option in the mount command to make our host system's /dev structure appear in the new CLFS filesystem:

    /tools/bin/mount -o bind /dev $LFS/dev

Additional file systems will soon be mounted from within the chroot environment. To keep the host up to date, perform a “fake mount” for each of these now:

    mount -f -vt tmpfs tmpfs $LFS/dev/shm
    mount -f -vt devpts -o gid=10,mode=620 devpts $LFS/dev/pts

- Prev

  Util-linux-2.12r

- Next

  Entering the Chroot Environment

- Up.
- Home.