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"> <sect2 id="ch-tools-bindmount">
<title>Mounting and Populating /dev</title> <title>Mounting and Populating /dev</title>
<para>During a normal boot, the kernel automatically mounts the <para>During a normal boot of the LFS system, the kernel automatically
<systemitem class="filesystem">devtmpfs</systemitem> filesystem on the mounts the <systemitem class="filesystem">devtmpfs</systemitem>
<filename class="directory">/dev</filename> directory; the filesystem on the
devices are created dynamically on that virtual filesystem when they <filename class="directory">/dev</filename> directory; the kernel
are first detected or accessed. Device creation is generally done during the creates device on that virtual filesystem during the boot process
boot process by the kernel and the udev program. or when a device is first detected or accessed. The udev daemon may
Since the new system does not yet include udev and change the owner or permission of the device nodes created by the
has not yet been booted, it is necessary to mount and populate kernel, or create new device nodes or symlinks to ease the work of
the <filename class="directory">/dev</filename> directory manually. This is distro maintainers or system administrators. (See
accomplished by bind mounting the host system's <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 <filename class="directory">/dev</filename> directory. A bind mount is
a special type of mount that allows you to create a mirror of a 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 directory or mount point at some other location. Use the following

View File

@ -93,7 +93,7 @@
</sect3> </sect3>
<sect3> <sect3 id='ch-config-udev-device-node-creation'>
<title>Device Node Creation</title> <title>Device Node Creation</title>
<para>Device files are created by the kernel by the <systemitem <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 root "<systemitem class='username'>root</systemitem>">
<!ENTITY lfs-user "<systemitem class='username'>lfs</systemitem>"> <!ENTITY lfs-user "<systemitem class='username'>lfs</systemitem>">
<!ENTITY devtmpfs "<systemitem class='filesystem'>devtmpfs</systemitem>">
<!ENTITY fstab "<filename>/etc/fstab</filename>"> <!ENTITY fstab "<filename>/etc/fstab</filename>">
<!ENTITY boot-dir "<filename class='directory'>/boot</filename>"> <!ENTITY boot-dir "<filename class='directory'>/boot</filename>">
<!ENTITY ch-final "<xref linkend='chapter-building-system'/>"> <!ENTITY ch-final "<xref linkend='chapter-building-system'/>">