source: chapter07/kernfs.xml@ 83d8de03

arm
Last change on this file since 83d8de03 was 83d8de03, checked in by William Harrington <kb0iic@…>, 2 years ago

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.

  • Property mode set to 100644
File size: 3.8 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="ch-tools-kernfs">
9 <?dbhtml filename="kernfs.html"?>
10
11 <title>Preparing Virtual Kernel File Systems</title>
12
13 <indexterm zone="ch-tools-kernfs">
14 <primary sortas="e-/dev/">/dev/*</primary>
15 </indexterm>
16
17 <para>Various file systems exported by the kernel are used to communicate to
18 and from the kernel itself. These file systems are virtual in that no disk
19 space is used for them. The content of the file systems resides in
20 memory.</para>
21
22 <para>Begin by creating directories onto which the file systems will be
23 mounted:</para>
24
25<screen><userinput>mkdir -pv $LFS/{dev,proc,sys,run}</userinput></screen>
26
27 <sect2 id="ch-tools-bindmount">
28 <title>Mounting and Populating /dev</title>
29
30 <para>During a normal boot, the kernel automatically mounts the
31 <systemitem class="filesystem">devtmpfs</systemitem> filesystem on the
32 <filename class="directory">/dev</filename> directory, and allow the
33 devices to be created dynamically on that virtual filesystem as they
34 are detected or accessed. Device creation is generally done during the
35 boot process by Udev. Since this new system does not yet have Udev and
36 has not yet been booted, it is necessary to mount and populate
37 <filename class="directory">/dev</filename> manually. This is
38 accomplished by bind mounting the host system's
39 <filename class="directory">/dev</filename> directory. A bind mount is
40 a special type of mount that allows you to create a mirror of a
41 directory or mount point to some other location. Use the following
42 command to achieve this:</para>
43
44<screen><userinput>mount -v --bind /dev $LFS/dev</userinput></screen>
45
46 </sect2>
47
48 <sect2 id="ch-tools-kernfsmount">
49 <title>Mounting Virtual Kernel File Systems</title>
50
51 <para>Now mount the remaining virtual kernel filesystems:</para>
52
53<screen><userinput>mount -v --bind /dev/pts $LFS/dev/pts
54mount -vt proc proc $LFS/proc
55mount -vt sysfs sysfs $LFS/sys
56mount -vt tmpfs tmpfs $LFS/run</userinput></screen>
57<!--
58 <variablelist>
59 <title>The meaning of the mount options for devpts:</title>
60
61 <varlistentry>
62 <term><parameter>gid=5</parameter></term>
63 <listitem>
64 <para>This ensures that all devpts-created device nodes are owned by
65 group ID 5. This is the ID we will use later on for the <systemitem
66 class="groupname">tty</systemitem> group. We use the group ID instead
67 of a name, since the host system might use a different ID for its
68 <systemitem class="groupname">tty</systemitem> group.</para>
69 </listitem>
70 </varlistentry>
71
72 <varlistentry>
73 <term><parameter>mode=0620</parameter></term>
74 <listitem>
75 <para>This ensures that all devpts-created device nodes have mode 0620
76 (user readable and writable, group writable). Together with the
77 option above, this ensures that devpts will create device nodes that
78 meet the requirements of grantpt(), meaning the Glibc
79 <command>pt_chown</command> helper binary (which is not installed by
80 default) is not necessary.</para>
81 </listitem>
82 </varlistentry>
83
84 </variablelist>
85-->
86 <para>In some host systems, <filename>/dev/shm</filename> is a
87 symbolic link to <filename class="directory">/run/shm</filename>.
88 The /run tmpfs was mounted above so in this case only a
89 directory needs to be created.</para>
90
91<screen><userinput>if [ -h $LFS/dev/shm ]; then
92 mkdir -pv $LFS/$(readlink $LFS/dev/shm)
93fi</userinput></screen>
94
95 </sect2>
96
97</sect1>
Note: See TracBrowser for help on using the repository browser.