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>Applications running in user space utilize various file
|
---|
18 | systems exported by the kernel to communicate
|
---|
19 | with the kernel itself. These file systems are virtual: no disk
|
---|
20 | space is used for them. The content of the file systems resides in
|
---|
21 | memory. These file systems must be mounted in the $LFS directory tree
|
---|
22 | so the applications can find them in the chroot environment.</para>
|
---|
23 |
|
---|
24 | <para>Begin by creating directories on which the file systems will be
|
---|
25 | mounted:</para>
|
---|
26 |
|
---|
27 | <screen><userinput>mkdir -pv $LFS/{dev,proc,sys,run}</userinput></screen>
|
---|
28 |
|
---|
29 | <sect2 id="ch-tools-bindmount">
|
---|
30 | <title>Mounting and Populating /dev</title>
|
---|
31 |
|
---|
32 | <para>During a normal boot, the kernel automatically mounts the
|
---|
33 | <systemitem class="filesystem">devtmpfs</systemitem> filesystem on the
|
---|
34 | <filename class="directory">/dev</filename> directory; the
|
---|
35 | devices are created dynamically on that virtual filesystem when they
|
---|
36 | are first detected or accessed. Device creation is generally done during the
|
---|
37 | boot process by the kernel and the udev program.
|
---|
38 | Since the new system does not yet include udev and
|
---|
39 | has not yet been booted, it is necessary to mount and populate
|
---|
40 | the <filename class="directory">/dev</filename> directory manually. This is
|
---|
41 | accomplished by bind mounting the host system's
|
---|
42 | <filename class="directory">/dev</filename> directory. A bind mount is
|
---|
43 | a special type of mount that allows you to create a mirror of a
|
---|
44 | directory or mount point at some other location. Use the following
|
---|
45 | command to do this:</para>
|
---|
46 |
|
---|
47 | <screen><userinput>mount -v --bind /dev $LFS/dev</userinput></screen>
|
---|
48 |
|
---|
49 | </sect2>
|
---|
50 |
|
---|
51 | <sect2 id="ch-tools-kernfsmount">
|
---|
52 | <title>Mounting Virtual Kernel File Systems</title>
|
---|
53 |
|
---|
54 | <para>Now mount the remaining virtual kernel filesystems:</para>
|
---|
55 |
|
---|
56 | <screen><userinput>mount -v --bind /dev/pts $LFS/dev/pts
|
---|
57 | mount -vt proc proc $LFS/proc
|
---|
58 | mount -vt sysfs sysfs $LFS/sys
|
---|
59 | mount -vt tmpfs tmpfs $LFS/run</userinput></screen>
|
---|
60 | <!--
|
---|
61 | <variablelist>
|
---|
62 | <title>The meaning of the mount options for devpts:</title>
|
---|
63 |
|
---|
64 | <varlistentry>
|
---|
65 | <term><parameter>gid=5</parameter></term>
|
---|
66 | <listitem>
|
---|
67 | <para>This ensures that all devpts-created device nodes are owned by
|
---|
68 | group ID 5. This is the ID we will use later on for the <systemitem
|
---|
69 | class="groupname">tty</systemitem> group. We use the group ID instead
|
---|
70 | of a name, since the host system might use a different ID for its
|
---|
71 | <systemitem class="groupname">tty</systemitem> group.</para>
|
---|
72 | </listitem>
|
---|
73 | </varlistentry>
|
---|
74 |
|
---|
75 | <varlistentry>
|
---|
76 | <term><parameter>mode=0620</parameter></term>
|
---|
77 | <listitem>
|
---|
78 | <para>This ensures that all devpts-created device nodes have mode 0620
|
---|
79 | (user readable and writable, group writable). Together with the
|
---|
80 | option above, this ensures that devpts will create device nodes that
|
---|
81 | meet the requirements of grantpt(), meaning the Glibc
|
---|
82 | <command>pt_chown</command> helper binary (which is not installed by
|
---|
83 | default) is not necessary.</para>
|
---|
84 | </listitem>
|
---|
85 | </varlistentry>
|
---|
86 |
|
---|
87 | </variablelist>
|
---|
88 | -->
|
---|
89 | <para>In some host systems, <filename>/dev/shm</filename> is a
|
---|
90 | symbolic link to <filename class="directory">/run/shm</filename>.
|
---|
91 | The /run tmpfs was mounted above so in this case only a
|
---|
92 | directory needs to be created.</para>
|
---|
93 |
|
---|
94 | <para>In other host systems <filename>/dev/shm</filename> is a mount point
|
---|
95 | for a tmpfs. In that case the mount of /dev above will only create
|
---|
96 | /dev/shm as a directory in the chroot environment. In this situation
|
---|
97 | we must explicitly mount a tmpfs:</para>
|
---|
98 |
|
---|
99 | <screen><userinput>if [ -h $LFS/dev/shm ]; then
|
---|
100 | mkdir -pv $LFS/$(readlink $LFS/dev/shm)
|
---|
101 | else
|
---|
102 | mount -t tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm
|
---|
103 | fi</userinput></screen>
|
---|
104 |
|
---|
105 | </sect2>
|
---|
106 |
|
---|
107 | </sect1>
|
---|