[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 |
|
---|
| 17 | <para>Various file systems exported by the kernel are used to communicate to
|
---|
| 18 | and from the kernel itself. These file systems are virtual in that no disk
|
---|
| 19 | space is used for them. The content of the file systems resides in
|
---|
| 20 | memory.</para>
|
---|
| 21 |
|
---|
| 22 | <para>Begin by creating directories onto which the file systems will be
|
---|
| 23 | mounted:</para>
|
---|
| 24 |
|
---|
| 25 | <screen><userinput>mkdir -pv $LFS/{dev,proc,sys,run}</userinput></screen>
|
---|
| 26 |
|
---|
[bfab1b2] | 27 | <sect2 id="ch-tools-bindmount">
|
---|
[fcc02767] | 28 | <title>Mounting and Populating /dev</title>
|
---|
| 29 |
|
---|
[940c8495] | 30 | <para>During a normal boot, the kernel automatically mounts the
|
---|
| 31 | <systemitem class="filesystem">devtmpfs</systemitem> filesystem on the
|
---|
| 32 | <filename class="directory">/dev</filename> directory, and allow the
|
---|
| 33 | devices to be created dynamically on that virtual filesystem as they
|
---|
| 34 | are detected or accessed. Device creation is generally done during the
|
---|
[ac47b25] | 35 | boot process by the kernel and Udev.
|
---|
| 36 | Since this new system does not yet have Udev and
|
---|
[940c8495] | 37 | has not yet been booted, it is necessary to mount and populate
|
---|
| 38 | <filename class="directory">/dev</filename> manually. This is
|
---|
| 39 | accomplished by bind mounting the host system's
|
---|
| 40 | <filename class="directory">/dev</filename> directory. A bind mount is
|
---|
| 41 | a special type of mount that allows you to create a mirror of a
|
---|
| 42 | directory or mount point to some other location. Use the following
|
---|
| 43 | command to achieve this:</para>
|
---|
[fcc02767] | 44 |
|
---|
| 45 | <screen><userinput>mount -v --bind /dev $LFS/dev</userinput></screen>
|
---|
| 46 |
|
---|
| 47 | </sect2>
|
---|
| 48 |
|
---|
[bfab1b2] | 49 | <sect2 id="ch-tools-kernfsmount">
|
---|
[fcc02767] | 50 | <title>Mounting Virtual Kernel File Systems</title>
|
---|
| 51 |
|
---|
| 52 | <para>Now mount the remaining virtual kernel filesystems:</para>
|
---|
| 53 |
|
---|
| 54 | <screen><userinput>mount -v --bind /dev/pts $LFS/dev/pts
|
---|
| 55 | mount -vt proc proc $LFS/proc
|
---|
| 56 | mount -vt sysfs sysfs $LFS/sys
|
---|
| 57 | mount -vt tmpfs tmpfs $LFS/run</userinput></screen>
|
---|
[387a32af] | 58 | <!--
|
---|
[fcc02767] | 59 | <variablelist>
|
---|
| 60 | <title>The meaning of the mount options for devpts:</title>
|
---|
| 61 |
|
---|
| 62 | <varlistentry>
|
---|
| 63 | <term><parameter>gid=5</parameter></term>
|
---|
| 64 | <listitem>
|
---|
| 65 | <para>This ensures that all devpts-created device nodes are owned by
|
---|
| 66 | group ID 5. This is the ID we will use later on for the <systemitem
|
---|
| 67 | class="groupname">tty</systemitem> group. We use the group ID instead
|
---|
| 68 | of a name, since the host system might use a different ID for its
|
---|
| 69 | <systemitem class="groupname">tty</systemitem> group.</para>
|
---|
| 70 | </listitem>
|
---|
| 71 | </varlistentry>
|
---|
| 72 |
|
---|
| 73 | <varlistentry>
|
---|
| 74 | <term><parameter>mode=0620</parameter></term>
|
---|
| 75 | <listitem>
|
---|
| 76 | <para>This ensures that all devpts-created device nodes have mode 0620
|
---|
| 77 | (user readable and writable, group writable). Together with the
|
---|
| 78 | option above, this ensures that devpts will create device nodes that
|
---|
| 79 | meet the requirements of grantpt(), meaning the Glibc
|
---|
| 80 | <command>pt_chown</command> helper binary (which is not installed by
|
---|
| 81 | default) is not necessary.</para>
|
---|
| 82 | </listitem>
|
---|
| 83 | </varlistentry>
|
---|
| 84 |
|
---|
| 85 | </variablelist>
|
---|
[387a32af] | 86 | -->
|
---|
[fcc02767] | 87 | <para>In some host systems, <filename>/dev/shm</filename> is a
|
---|
| 88 | symbolic link to <filename class="directory">/run/shm</filename>.
|
---|
[2c8fdfc] | 89 | The /run tmpfs was mounted above so in this case only a
|
---|
[fcc02767] | 90 | directory needs to be created.</para>
|
---|
| 91 |
|
---|
| 92 | <screen><userinput>if [ -h $LFS/dev/shm ]; then
|
---|
| 93 | mkdir -pv $LFS/$(readlink $LFS/dev/shm)
|
---|
| 94 | fi</userinput></screen>
|
---|
| 95 |
|
---|
| 96 | </sect2>
|
---|
| 97 |
|
---|
| 98 | </sect1>
|
---|