[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 |
|
---|
[7ae2811] | 17 | <para>Applications running in userspace utilize various file
|
---|
[ebecd08] | 18 | systems created by the kernel to communicate
|
---|
[29526d3] | 19 | with the kernel itself. These file systems are virtual: no disk
|
---|
[ebecd08] | 20 | space is used for them. The content of these file systems resides in
|
---|
[ef1f48b] | 21 | memory.</para>
|
---|
[fcc02767] | 22 |
|
---|
[ebecd08] | 23 | <para>Begin by creating the directories on which these virtual 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>.
|
---|
[b59b371] | 33 | Mount the remaining virtual kernel file systems:</para>
|
---|
[febac51] | 34 |
|
---|
| 35 | <screen><userinput>mkdir -pv /dev/{pts,shm}
|
---|
| 36 | mount -vt devpts /dev/pts /dev/pts -o gid=5,mode=620
|
---|
| 37 | mount -vt proc proc /proc
|
---|
| 38 | mount -vt sysfs sysfs /sys
|
---|
| 39 | mount -vt tmpfs tmpfs /run
|
---|
[d963661] | 40 | mount -vt tmpfs tmpfs /dev/shm -o nosuid,nodev</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
|
---|
| 85 | ln -sfv /proc/self/fd/1 /dev/stdout
|
---|
[d35dc01] | 86 | ln -sfv /proc/self/fd/2 /dev/stderr
|
---|
| 87 | ln -sv /proc/self/fd /dev</userinput></screen>
|
---|
[fcc02767] | 88 |
|
---|
| 89 | </sect2>
|
---|
| 90 |
|
---|
| 91 | </sect1>
|
---|