source: chapter07/kernfs.xml@ ef1f48b

xry111/clfs-ng
Last change on this file since ef1f48b was ef1f48b, checked in by Xi Ruoyao <xry111@…>, 19 months ago

clfs-ng: kernfs: remove "chroot" merged from trunk

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