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 /{proc,sys,run}</userinput></screen>
|
---|
26 |
|
---|
27 | <sect2 id="ch-tools-kernfsmount">
|
---|
28 | <title>Mounting Virtual Kernel File Systems</title>
|
---|
29 |
|
---|
30 | <para>The kernel has already mounted
|
---|
31 | <systemitem class="filesystem">devtmpfs</systemitem>.
|
---|
32 | Mount the remaining virtual kernel filesystems:</para>
|
---|
33 |
|
---|
34 | <screen><userinput>mkdir -pv /dev/{pts,shm}
|
---|
35 | mount -vt devpts /dev/pts /dev/pts -o gid=5,mode=620
|
---|
36 | mount -vt proc proc /proc
|
---|
37 | mount -vt sysfs sysfs /sys
|
---|
38 | mount -vt tmpfs tmpfs /run
|
---|
39 | mount -vt tmpfs tmpfs /dev/shm</userinput></screen>
|
---|
40 |
|
---|
41 | <variablelist>
|
---|
42 | <title>The meaning of the mount options for devpts:</title>
|
---|
43 |
|
---|
44 | <varlistentry>
|
---|
45 | <term><parameter>gid=5</parameter></term>
|
---|
46 | <listitem>
|
---|
47 | <para>This ensures that all devpts-created device nodes are owned by
|
---|
48 | group ID 5. This is the ID we will use later on for the <systemitem
|
---|
49 | class="groupname">tty</systemitem> group. We use the group ID instead
|
---|
50 | of a name, since the host system might use a different ID for its
|
---|
51 | <systemitem class="groupname">tty</systemitem> group.</para>
|
---|
52 | </listitem>
|
---|
53 | </varlistentry>
|
---|
54 |
|
---|
55 | <varlistentry>
|
---|
56 | <term><parameter>mode=0620</parameter></term>
|
---|
57 | <listitem>
|
---|
58 | <para>This ensures that all devpts-created device nodes have mode 0620
|
---|
59 | (user readable and writable, group writable). Together with the
|
---|
60 | option above, this ensures that devpts will create device nodes that
|
---|
61 | meet the requirements of grantpt(), meaning the Glibc
|
---|
62 | <command>pt_chown</command> helper binary (which is not installed by
|
---|
63 | default) is not necessary.</para>
|
---|
64 | </listitem>
|
---|
65 | </varlistentry>
|
---|
66 |
|
---|
67 | </variablelist>
|
---|
68 |
|
---|
69 | </sect2>
|
---|
70 |
|
---|
71 | <sect2 id="ch-tools-devadjust">
|
---|
72 | <title>Adjusting devtmpfs</title>
|
---|
73 |
|
---|
74 | <para>Now <systemitem class='filesystem'>proc</systemitem> filesystem
|
---|
75 | is mounted, we can replace the device nodes for standard I/O streams
|
---|
76 | with symlinks to pseudo files in
|
---|
77 | <filename class="directory">/proc/self/fd</filename> (which are symlinks
|
---|
78 | to the files connected to the standard I/O streams for the current
|
---|
79 | process). And, create another symlink recommended by the kernel
|
---|
80 | documentation. These are necessary for I/O redirection in the building
|
---|
81 | system of some packages to function properly:</para>
|
---|
82 |
|
---|
83 | <screen><userinput>ln -sfv /proc/self/fd/0 /dev/stdin
|
---|
84 | ln -sfv /proc/self/fd/1 /dev/stdout
|
---|
85 | ln -sfv /proc/self/fd/2 /dev/stderr
|
---|
86 | ln -sv /proc/self/fd /dev</userinput></screen>
|
---|
87 |
|
---|
88 | <para>In other cases <filename>/dev/shm</filename> is a mountpoint
|
---|
89 | for a tmpfs. In that case the mount of /dev above will only create
|
---|
90 | /dev/shm in the chroot environment as a directory. In this situation
|
---|
91 | we explicitly mount a tmpfs,</para>
|
---|
92 |
|
---|
93 | <screen><userinput>if [ -h $LFS/dev/shm ]; then
|
---|
94 | mkdir -pv $LFS/$(readlink $LFS/dev/shm)
|
---|
95 | else
|
---|
96 | mount -t tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm
|
---|
97 | fi</userinput></screen>
|
---|
98 |
|
---|
99 | </sect2>
|
---|
100 |
|
---|
101 | </sect1>
|
---|