[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
|
---|
[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 |
|
---|
[29526d3] | 24 | <para>Begin by creating directories on which the 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 |
|
---|
[0058818] | 32 | <para>During a normal boot of the LFS system, the kernel automatically
|
---|
| 33 | mounts the <systemitem class="filesystem">devtmpfs</systemitem>
|
---|
| 34 | filesystem on the
|
---|
| 35 | <filename class="directory">/dev</filename> directory; the kernel
|
---|
[2bf32ff] | 36 | creates device nodes on that virtual filesystem during the boot process
|
---|
[0058818] | 37 | or when a device is first detected or accessed. The udev daemon may
|
---|
| 38 | change the owner or permission of the device nodes created by the
|
---|
| 39 | kernel, or create new device nodes or symlinks to ease the work of
|
---|
| 40 | distro maintainers or system administrators. (See
|
---|
| 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
|
---|
| 44 | on the kernel to populate it (the LFS building process does not need
|
---|
| 45 | the additional work onto &devtmpfs; by udev daemon).</para>
|
---|
| 46 |
|
---|
| 47 | <para>But, some host kernels may lack &devtmpfs; support and these
|
---|
| 48 | host distros maintain the content of
|
---|
| 49 | <filename class="directory">/dev</filename> with different methods.
|
---|
| 50 | So the only host-agnostic way for populating
|
---|
| 51 | <filename class="directory">$LFS/dev</filename> is
|
---|
| 52 | bind mounting the host system's
|
---|
[940c8495] | 53 | <filename class="directory">/dev</filename> directory. A bind mount is
|
---|
| 54 | a special type of mount that allows you to create a mirror of a
|
---|
[29526d3] | 55 | directory or mount point at some other location. Use the following
|
---|
| 56 | command to do this:</para>
|
---|
[fcc02767] | 57 |
|
---|
| 58 | <screen><userinput>mount -v --bind /dev $LFS/dev</userinput></screen>
|
---|
| 59 |
|
---|
| 60 | </sect2>
|
---|
| 61 |
|
---|
[bfab1b2] | 62 | <sect2 id="ch-tools-kernfsmount">
|
---|
[fcc02767] | 63 | <title>Mounting Virtual Kernel File Systems</title>
|
---|
| 64 |
|
---|
| 65 | <para>Now mount the remaining virtual kernel filesystems:</para>
|
---|
| 66 |
|
---|
| 67 | <screen><userinput>mount -v --bind /dev/pts $LFS/dev/pts
|
---|
| 68 | mount -vt proc proc $LFS/proc
|
---|
| 69 | mount -vt sysfs sysfs $LFS/sys
|
---|
| 70 | mount -vt tmpfs tmpfs $LFS/run</userinput></screen>
|
---|
[387a32af] | 71 | <!--
|
---|
[fcc02767] | 72 | <variablelist>
|
---|
| 73 | <title>The meaning of the mount options for devpts:</title>
|
---|
| 74 |
|
---|
| 75 | <varlistentry>
|
---|
| 76 | <term><parameter>gid=5</parameter></term>
|
---|
| 77 | <listitem>
|
---|
| 78 | <para>This ensures that all devpts-created device nodes are owned by
|
---|
| 79 | group ID 5. This is the ID we will use later on for the <systemitem
|
---|
| 80 | class="groupname">tty</systemitem> group. We use the group ID instead
|
---|
| 81 | of a name, since the host system might use a different ID for its
|
---|
| 82 | <systemitem class="groupname">tty</systemitem> group.</para>
|
---|
| 83 | </listitem>
|
---|
| 84 | </varlistentry>
|
---|
| 85 |
|
---|
| 86 | <varlistentry>
|
---|
| 87 | <term><parameter>mode=0620</parameter></term>
|
---|
| 88 | <listitem>
|
---|
| 89 | <para>This ensures that all devpts-created device nodes have mode 0620
|
---|
| 90 | (user readable and writable, group writable). Together with the
|
---|
| 91 | option above, this ensures that devpts will create device nodes that
|
---|
| 92 | meet the requirements of grantpt(), meaning the Glibc
|
---|
| 93 | <command>pt_chown</command> helper binary (which is not installed by
|
---|
| 94 | default) is not necessary.</para>
|
---|
| 95 | </listitem>
|
---|
| 96 | </varlistentry>
|
---|
| 97 |
|
---|
| 98 | </variablelist>
|
---|
[387a32af] | 99 | -->
|
---|
[fcc02767] | 100 | <para>In some host systems, <filename>/dev/shm</filename> is a
|
---|
| 101 | symbolic link to <filename class="directory">/run/shm</filename>.
|
---|
[2c8fdfc] | 102 | The /run tmpfs was mounted above so in this case only a
|
---|
[fcc02767] | 103 | directory needs to be created.</para>
|
---|
| 104 |
|
---|
[29526d3] | 105 | <para>In other host systems <filename>/dev/shm</filename> is a mount point
|
---|
[16cd0963] | 106 | for a tmpfs. In that case the mount of /dev above will only create
|
---|
[29526d3] | 107 | /dev/shm as a directory in the chroot environment. In this situation
|
---|
| 108 | we must explicitly mount a tmpfs:</para>
|
---|
[16cd0963] | 109 |
|
---|
[fcc02767] | 110 | <screen><userinput>if [ -h $LFS/dev/shm ]; then
|
---|
| 111 | mkdir -pv $LFS/$(readlink $LFS/dev/shm)
|
---|
[16cd0963] | 112 | else
|
---|
| 113 | mount -t tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm
|
---|
[fcc02767] | 114 | fi</userinput></screen>
|
---|
| 115 |
|
---|
| 116 | </sect2>
|
---|
| 117 |
|
---|
| 118 | </sect1>
|
---|