kernfs: modernize the explanation for bind mounting /dev

If you are using a "modern" distro (with devtmpfs and a modern udev
implementation), a bind mounting is actually not needed because you can
mount devtmpfs anyway.  The only reason for bind mounting is to be
compatible with old host distros where /dev is a directory containing
many static device nodes, or is a tmpfs (not same as devtmpfs) popluated
by bootscript or an old udev (modern udev implementations, including
eudev and systemd-udev used by LFS, strictly requires a devtmpfs on
/dev).

So update the explanation to match the status quo.
This commit is contained in:
Xi Ruoyao 2022-10-01 15:14:22 +08:00
parent a8f3814a7b
commit 00588180ee
No known key found for this signature in database
GPG Key ID: ACAAD20E19E710E3
3 changed files with 23 additions and 11 deletions

View File

@ -29,16 +29,27 @@
<sect2 id="ch-tools-bindmount">
<title>Mounting and Populating /dev</title>
<para>During a normal boot, the kernel automatically mounts the
<systemitem class="filesystem">devtmpfs</systemitem> filesystem on the
<filename class="directory">/dev</filename> directory; the
devices are created dynamically on that virtual filesystem when they
are first detected or accessed. Device creation is generally done during the
boot process by the kernel and the udev program.
Since the new system does not yet include udev and
has not yet been booted, it is necessary to mount and populate
the <filename class="directory">/dev</filename> directory manually. This is
accomplished by bind mounting the host system's
<para>During a normal boot of the LFS system, the kernel automatically
mounts the <systemitem class="filesystem">devtmpfs</systemitem>
filesystem on the
<filename class="directory">/dev</filename> directory; the kernel
creates device on that virtual filesystem during the boot process
or when a device is first detected or accessed. The udev daemon may
change the owner or permission of the device nodes created by the
kernel, or create new device nodes or symlinks to ease the work of
distro maintainers or system administrators. (See
<xref linkend='ch-config-udev-device-node-creation'/> for details.)
If the host kernel supports &devtmpfs;, we can simply mount a
&devtmpfs; at <filename class='directory'>$LFS/dev</filename> and rely
on the kernel to populate it (the LFS building process does not need
the additional work onto &devtmpfs; by udev daemon).</para>
<para>But, some host kernels may lack &devtmpfs; support and these
host distros maintain the content of
<filename class="directory">/dev</filename> with different methods.
So the only host-agnostic way for populating
<filename class="directory">$LFS/dev</filename> is
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 at some other location. Use the following

View File

@ -93,7 +93,7 @@
</sect3>
<sect3>
<sect3 id='ch-config-udev-device-node-creation'>
<title>Device Node Creation</title>
<para>Device files are created by the kernel by the <systemitem

View File

@ -121,6 +121,7 @@
<!ENTITY root "<systemitem class='username'>root</systemitem>">
<!ENTITY lfs-user "<systemitem class='username'>lfs</systemitem>">
<!ENTITY devtmpfs "<systemitem class='filesystem'>devtmpfs</systemitem>">
<!ENTITY fstab "<filename>/etc/fstab</filename>">
<!ENTITY boot-dir "<filename class='directory'>/boot</filename>">
<!ENTITY ch-final "<xref linkend='chapter-building-system'/>">