[7152faa] | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
[fcc02767] | 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
|
---|
[a8f3814a] | 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>
|
---|
[fcc02767] | 23 |
|
---|
[ebecd08] | 24 | <para>Begin by creating the directories on which these virtual file systems will be
|
---|
[fcc02767] | 25 | mounted:</para>
|
---|
| 26 |
|
---|
| 27 | <screen><userinput>mkdir -pv $LFS/{dev,proc,sys,run}</userinput></screen>
|
---|
| 28 |
|
---|
[bfab1b2] | 29 | <sect2 id="ch-tools-bindmount">
|
---|
[fcc02767] | 30 | <title>Mounting and Populating /dev</title>
|
---|
| 31 |
|
---|
[ebecd08] | 32 | <para>During a normal boot of an LFS system, the kernel automatically
|
---|
[0058818] | 33 | mounts the <systemitem class="filesystem">devtmpfs</systemitem>
|
---|
[ebecd08] | 34 | file system on the
|
---|
[0058818] | 35 | <filename class="directory">/dev</filename> directory; the kernel
|
---|
[ebecd08] | 36 | creates device nodes on that virtual file system during the boot process,
|
---|
[0058818] | 37 | or when a device is first detected or accessed. The udev daemon may
|
---|
[ebecd08] | 38 | change the ownership or permissions of the device nodes created by the
|
---|
| 39 | kernel, and create new device nodes or symlinks, to ease the work of
|
---|
| 40 | distro maintainers and system administrators. (See
|
---|
[0058818] | 41 | <xref linkend='ch-config-udev-device-node-creation'/> for details.)
|
---|
| 42 | If the host kernel supports &devtmpfs;, we can simply mount a
|
---|
| 43 | &devtmpfs; at <filename class='directory'>$LFS/dev</filename> and rely
|
---|
[2f9498af] | 44 | on the kernel to populate it.</para>
|
---|
[0058818] | 45 |
|
---|
[ebecd08] | 46 | <para>But some host kernels lack &devtmpfs; support; these
|
---|
| 47 | host distros use different methods to create the content of
|
---|
| 48 | <filename class="directory">/dev</filename>.
|
---|
| 49 | So the only host-agnostic way to populate the
|
---|
| 50 | <filename class="directory">$LFS/dev</filename> directory is
|
---|
| 51 | by bind mounting the host system's
|
---|
[940c8495] | 52 | <filename class="directory">/dev</filename> directory. A bind mount is
|
---|
[9407694] | 53 | a special type of mount that makes a directory subtree or a file
|
---|
| 54 | visible at some other location. Use the following
|
---|
[ebecd08] | 55 | command to do this.</para>
|
---|
[fcc02767] | 56 |
|
---|
| 57 | <screen><userinput>mount -v --bind /dev $LFS/dev</userinput></screen>
|
---|
| 58 |
|
---|
| 59 | </sect2>
|
---|
| 60 |
|
---|
[bfab1b2] | 61 | <sect2 id="ch-tools-kernfsmount">
|
---|
[fcc02767] | 62 | <title>Mounting Virtual Kernel File Systems</title>
|
---|
| 63 |
|
---|
[ebecd08] | 64 | <para>Now mount the remaining virtual kernel file systems:</para>
|
---|
[fcc02767] | 65 |
|
---|
[ce11e97] | 66 | <!-- Do not put any option after $LFS/${mountpoint} or jhalfs cannot
|
---|
| 67 | handle it! -->
|
---|
| 68 |
|
---|
| 69 | <screen><userinput>mount -vt devpts devpts -o gid=5,mode=0620 $LFS/dev/pts
|
---|
[fcc02767] | 70 | mount -vt proc proc $LFS/proc
|
---|
| 71 | mount -vt sysfs sysfs $LFS/sys
|
---|
| 72 | mount -vt tmpfs tmpfs $LFS/run</userinput></screen>
|
---|
[ce11e97] | 73 |
|
---|
[fcc02767] | 74 | <variablelist>
|
---|
| 75 | <title>The meaning of the mount options for devpts:</title>
|
---|
| 76 |
|
---|
| 77 | <varlistentry>
|
---|
| 78 | <term><parameter>gid=5</parameter></term>
|
---|
| 79 | <listitem>
|
---|
| 80 | <para>This ensures that all devpts-created device nodes are owned by
|
---|
| 81 | group ID 5. This is the ID we will use later on for the <systemitem
|
---|
| 82 | class="groupname">tty</systemitem> group. We use the group ID instead
|
---|
| 83 | of a name, since the host system might use a different ID for its
|
---|
| 84 | <systemitem class="groupname">tty</systemitem> group.</para>
|
---|
| 85 | </listitem>
|
---|
| 86 | </varlistentry>
|
---|
| 87 |
|
---|
| 88 | <varlistentry>
|
---|
| 89 | <term><parameter>mode=0620</parameter></term>
|
---|
| 90 | <listitem>
|
---|
| 91 | <para>This ensures that all devpts-created device nodes have mode 0620
|
---|
| 92 | (user readable and writable, group writable). Together with the
|
---|
| 93 | option above, this ensures that devpts will create device nodes that
|
---|
| 94 | meet the requirements of grantpt(), meaning the Glibc
|
---|
| 95 | <command>pt_chown</command> helper binary (which is not installed by
|
---|
| 96 | default) is not necessary.</para>
|
---|
| 97 | </listitem>
|
---|
| 98 | </varlistentry>
|
---|
| 99 |
|
---|
| 100 | </variablelist>
|
---|
[ce11e97] | 101 |
|
---|
[fcc02767] | 102 | <para>In some host systems, <filename>/dev/shm</filename> is a
|
---|
[8cf42d4] | 103 | symbolic link to a directory, typically
|
---|
| 104 | <filename class="directory">/run/shm</filename>.
|
---|
[2c8fdfc] | 105 | The /run tmpfs was mounted above so in this case only a
|
---|
[1541b7c] | 106 | directory needs to be created with the correct permissions.</para>
|
---|
[fcc02767] | 107 |
|
---|
[29526d3] | 108 | <para>In other host systems <filename>/dev/shm</filename> is a mount point
|
---|
[16cd0963] | 109 | for a tmpfs. In that case the mount of /dev above will only create
|
---|
[29526d3] | 110 | /dev/shm as a directory in the chroot environment. In this situation
|
---|
| 111 | we must explicitly mount a tmpfs:</para>
|
---|
[16cd0963] | 112 |
|
---|
[fcc02767] | 113 | <screen><userinput>if [ -h $LFS/dev/shm ]; then
|
---|
[7436c28] | 114 | install -v -d -m 1777 $LFS$(realpath /dev/shm)
|
---|
[16cd0963] | 115 | else
|
---|
[e0a9427] | 116 | mount -vt tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm
|
---|
[fcc02767] | 117 | fi</userinput></screen>
|
---|
| 118 |
|
---|
| 119 | </sect2>
|
---|
| 120 |
|
---|
| 121 | </sect1>
|
---|