diff options
author | Xi Ruoyao <xry111@mengyan1223.wang> | 2022-03-08 01:19:06 +0800 |
---|---|---|
committer | Xi Ruoyao <xry111@mengyan1223.wang> | 2022-03-08 01:25:06 +0800 |
commit | 940c8495ae3e96d22856e51266bd02f0840de25a (patch) | |
tree | eaf2fa1e6442bd773c933200777f5bfeb6564adf | |
parent | 102a7f64c074baa465314620e2798d4031419fae (diff) |
kernfs: remove static node creation, and update the text
This is to match the "new" way of device handling with devtmpfs (already
widely used in recent ten years).
In a normal booting process, the kernel mounts devtmpfs at very early
stage. So the static nodes won't be used at all. The only situation
where the kernel can't mount devtmpfs is "/dev is missing", but it means
those two static nodes can't exist anyway, and a normal LFS system
(without initramfs) won't boot in such a bad situation.
Removing static /dev/console and /dev/null may cause trouble for those
people or scripts chroot into LFS tree without mounting devtmpfs. But
entering a chroot with only console and null in /dev is already
problematic. For a reference, If a systemd service is started with
PrivateDevices=true, systemd will create 18 nodes and symlinks to form a
"minimal" /dev.
-rw-r--r-- | chapter07/kernfs.xml | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/chapter07/kernfs.xml b/chapter07/kernfs.xml index f34155d7b..8746ea1e9 100644 --- a/chapter07/kernfs.xml +++ b/chapter07/kernfs.xml @@ -24,41 +24,22 @@ <screen><userinput>mkdir -pv $LFS/{dev,proc,sys,run}</userinput></screen> - <sect2> - <title>Creating Initial Device Nodes</title> - - <para>When the kernel boots the system, it requires the presence of a few - device nodes, in particular the <filename - class="devicefile">console</filename> and <filename - class="devicefile">null</filename> devices. The device nodes must be - created on the hard disk so that they are available before the kernel - populates <systemitem class="filesystem">/dev</systemitem>), and - additionally when Linux is started with - <parameter>init=/bin/bash</parameter>. Create the devices by running the - following commands:</para> - -<screen><userinput>mknod -m 600 $LFS/dev/console c 5 1 -mknod -m 666 $LFS/dev/null c 1 3</userinput></screen> - - </sect2> - <sect2 id="ch-tools-bindmount"> <title>Mounting and Populating /dev</title> - <para>The recommended method of populating the <filename - class="directory">/dev</filename> directory with devices is to mount a - virtual filesystem (such as <systemitem - class="filesystem">tmpfs</systemitem>) on the <filename - class="directory">/dev</filename> 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 <filename - class="directory">/dev</filename> manually. This is accomplished by bind - mounting the host system's <filename class="directory">/dev</filename> - 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:</para> + <para>During a normal boot, the kernel automatically mounts the + <systemitem class="filesystem">devtmpfs</systemitem> filesystem on the + <filename class="directory">/dev</filename> 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 + <filename class="directory">/dev</filename> manually. This is + accomplished by bind mounting the host system's + <filename class="directory">/dev</filename> 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:</para> <screen><userinput>mount -v --bind /dev $LFS/dev</userinput></screen> |