source: chapter07/kernfs.xml@ 2b63974

xry111/clfs-ng
Last change on this file since 2b63974 was 9e76c64, checked in by Xi Ruoyao <xry111@…>, 7 months ago

Merge remote-tracking branch 'origin/trunk' into xry111/clfs-ng

  • Property mode set to 100644
File size: 3.4 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
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 userspace utilize various file
18 systems created 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 these file systems resides in
21 memory.</para>
22
23 <para>Begin by creating the directories on which these virtual file systems will be
24 mounted:</para>
25
26<screen><userinput>mkdir -pv /{proc,sys,run}</userinput></screen>
27
28 <sect2 id="ch-tools-kernfsmount">
29 <title>Mounting Virtual Kernel File Systems</title>
30
31 <para>The kernel has already mounted
32 <systemitem class="filesystem">devtmpfs</systemitem>.
33 Mount the remaining virtual kernel file systems:</para>
34
35 <!-- Do not put any option after $LFS/${mountpoint} or jhalfs cannot
36 handle it! -->
37
38<screen><userinput>mkdir -pv /dev/{pts,shm}
39mount -vt devpts devpts -o gid=5,mode=0620 /dev/pts
40mount -vt proc proc /proc
41mount -vt sysfs sysfs /sys
42mount -vt tmpfs tmpfs /run
43mount -vt tmpfs tmpfs /dev/shm -o nosuid,nodev</userinput></screen>
44
45 <variablelist>
46 <title>The meaning of the mount options for devpts:</title>
47
48 <varlistentry>
49 <term><parameter>gid=5</parameter></term>
50 <listitem>
51 <para>This ensures that all devpts-created device nodes are owned by
52 group ID 5. This is the ID we will use later on for the <systemitem
53 class="groupname">tty</systemitem> group. We use the group ID instead
54 of a name, since the host system might use a different ID for its
55 <systemitem class="groupname">tty</systemitem> group.</para>
56 </listitem>
57 </varlistentry>
58
59 <varlistentry>
60 <term><parameter>mode=0620</parameter></term>
61 <listitem>
62 <para>This ensures that all devpts-created device nodes have mode 0620
63 (user readable and writable, group writable). Together with the
64 option above, this ensures that devpts will create device nodes that
65 meet the requirements of grantpt(), meaning the Glibc
66 <command>pt_chown</command> helper binary (which is not installed by
67 default) is not necessary.</para>
68 </listitem>
69 </varlistentry>
70
71 </variablelist>
72
73 </sect2>
74
75 <sect2 id="ch-tools-devadjust">
76 <title>Adjusting devtmpfs</title>
77
78 <para>Now with the
79 <systemitem class='filesystem'>proc</systemitem> filesystem
80 mounted, we can replace the device nodes for standard I/O streams
81 with symlinks to pseudo files in
82 <filename class="directory">/proc/self/fd</filename> (which are symlinks
83 to the files connected to the standard I/O streams for the current
84 process). And, create another symlink recommended by the kernel
85 documentation. These are necessary for I/O redirection in the building
86 system of some packages to function properly:</para>
87
88<screen><userinput>ln -sfv /proc/self/fd/0 /dev/stdin
89ln -sfv /proc/self/fd/1 /dev/stdout
90ln -sfv /proc/self/fd/2 /dev/stderr
91ln -sv /proc/self/fd /dev</userinput></screen>
92
93 </sect2>
94
95</sect1>
Note: See TracBrowser for help on using the repository browser.