source: chapter07/kernfs.xml@ 16cd0963

11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 bdubbs/gcc13 multilib renodr/libudev-from-systemd trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 16cd0963 was 16cd0963, checked in by Bruce Dubbs <bdubbs@…>, 20 months ago

Adjust instructions for /dev/shm when creating virtual filesystems.
Some host create /dev/shm as a tmpfs. Some have is as
a symlink to a location in another directory. This
change handles both cases.

The change to the sysV bootscripts now creates /dev/shm
as a separate tmpfs from /run. This makes LFS sysV and
systemd versions treat /dev/shm the same.

  • Property mode set to 100644
File size: 4.1 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 the kernel and Udev.
36 Since this new system does not yet have Udev and
37 has not yet been booted, it is necessary to mount and populate
38 <filename class="directory">/dev</filename> manually. This is
39 accomplished by bind mounting the host system's
40 <filename class="directory">/dev</filename> directory. A bind mount is
41 a special type of mount that allows you to create a mirror of a
42 directory or mount point to some other location. Use the following
43 command to achieve this:</para>
44
45<screen><userinput>mount -v --bind /dev $LFS/dev</userinput></screen>
46
47 </sect2>
48
49 <sect2 id="ch-tools-kernfsmount">
50 <title>Mounting Virtual Kernel File Systems</title>
51
52 <para>Now mount the remaining virtual kernel filesystems:</para>
53
54<screen><userinput>mount -v --bind /dev/pts $LFS/dev/pts
55mount -vt proc proc $LFS/proc
56mount -vt sysfs sysfs $LFS/sys
57mount -vt tmpfs tmpfs $LFS/run</userinput></screen>
58<!--
59 <variablelist>
60 <title>The meaning of the mount options for devpts:</title>
61
62 <varlistentry>
63 <term><parameter>gid=5</parameter></term>
64 <listitem>
65 <para>This ensures that all devpts-created device nodes are owned by
66 group ID 5. This is the ID we will use later on for the <systemitem
67 class="groupname">tty</systemitem> group. We use the group ID instead
68 of a name, since the host system might use a different ID for its
69 <systemitem class="groupname">tty</systemitem> group.</para>
70 </listitem>
71 </varlistentry>
72
73 <varlistentry>
74 <term><parameter>mode=0620</parameter></term>
75 <listitem>
76 <para>This ensures that all devpts-created device nodes have mode 0620
77 (user readable and writable, group writable). Together with the
78 option above, this ensures that devpts will create device nodes that
79 meet the requirements of grantpt(), meaning the Glibc
80 <command>pt_chown</command> helper binary (which is not installed by
81 default) is not necessary.</para>
82 </listitem>
83 </varlistentry>
84
85 </variablelist>
86-->
87 <para>In some host systems, <filename>/dev/shm</filename> is a
88 symbolic link to <filename class="directory">/run/shm</filename>.
89 The /run tmpfs was mounted above so in this case only a
90 directory needs to be created.</para>
91
92 <para>In other cases <filename>/dev/shm</filename> is a mountpoint
93 for a tmpfs. In that case the mount of /dev above will only create
94 /dev/shm in the chroot environment as a directory. In this situation
95 we explicitly mount a tmpfs,</para>
96
97<screen><userinput>if [ -h $LFS/dev/shm ]; then
98 mkdir -pv $LFS/$(readlink $LFS/dev/shm)
99else
100 mount -t tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm
101fi</userinput></screen>
102
103 </sect2>
104
105</sect1>
Note: See TracBrowser for help on using the repository browser.