source: chapter07/kernfs.xml@ dd61c77

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