Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • chapter07/kernfs.xml

    rce11e97 re49e2ea  
    1 <?xml version="1.0" encoding="UTF-8"?>
     1<?xml version="1.0" encoding="ISO-8859-1"?>
    22<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
    33  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
     
    1919    with the kernel itself. These file systems are virtual: no disk
    2020    space is used for them. The content of these file systems resides in
    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>
     21    memory.</para>
    2322
    2423    <para>Begin by creating the directories on which these virtual file systems will be
    2524    mounted:</para>
    2625
    27 <screen><userinput>mkdir -pv $LFS/{dev,proc,sys,run}</userinput></screen>
    28 
    29   <sect2 id="ch-tools-bindmount">
    30     <title>Mounting and Populating /dev</title>
    31 
    32       <para>During a normal boot of an LFS system, the kernel automatically
    33       mounts the <systemitem class="filesystem">devtmpfs</systemitem>
    34       file system on the
    35       <filename class="directory">/dev</filename> directory; the kernel
    36       creates device nodes on that virtual file system during the boot process,
    37       or when a device is first detected or accessed. The udev daemon may
    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
    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.</para>
    45 
    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
    52       <filename class="directory">/dev</filename> directory. A bind mount is
    53       a special type of mount that makes a directory subtree or a file
    54       visible at some other location. Use the following
    55       command to do this.</para>
    56 
    57 <screen><userinput>mount -v --bind /dev $LFS/dev</userinput></screen>
    58 
    59   </sect2>
     26<screen><userinput>mkdir -pv /{proc,sys,run}</userinput></screen>
    6027
    6128  <sect2 id="ch-tools-kernfsmount">
    6229    <title>Mounting Virtual Kernel File Systems</title>
    6330
    64       <para>Now mount the remaining virtual kernel file systems:</para>
     31    <para>The kernel has already mounted
     32    <systemitem class="filesystem">devtmpfs</systemitem>.
     33    Mount the remaining virtual kernel file systems:</para>
    6534
    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
    70 mount -vt proc proc $LFS/proc
    71 mount -vt sysfs sysfs $LFS/sys
    72 mount -vt tmpfs tmpfs $LFS/run</userinput></screen>
     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 -o nosuid,nodev</userinput></screen>
    7341
    7442    <variablelist>
     
    10068    </variablelist>
    10169
    102       <para>In some host systems, <filename>/dev/shm</filename> is a
    103       symbolic link to a directory, typically
    104       <filename class="directory">/run/shm</filename>.
    105       The /run tmpfs was mounted above so in this case only a
    106       directory needs to be created with the correct permissions.</para>
     70  </sect2>
    10771
    108       <para>In other host systems <filename>/dev/shm</filename> is a mount point
    109       for a tmpfs. In that case the mount of /dev above will only create
    110       /dev/shm as a directory in the chroot environment. In this situation
    111       we must explicitly mount a tmpfs:</para>
     72  <sect2 id="ch-tools-devadjust">
     73    <title>Adjusting devtmpfs</title>
    11274
    113 <screen><userinput>if [ -h $LFS/dev/shm ]; then
    114   install -v -d -m 1777 $LFS$(realpath /dev/shm)
    115 else
    116   mount -vt tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm
    117 fi</userinput></screen>
     75    <para>Now with the
     76    <systemitem class='filesystem'>proc</systemitem> filesystem
     77    mounted, we can replace the device nodes for standard I/O streams
     78    with symlinks to pseudo files in
     79    <filename class="directory">/proc/self/fd</filename> (which are symlinks
     80    to the files connected to the standard I/O streams for the current
     81    process).  And, create another symlink recommended by the kernel
     82    documentation.  These are necessary for I/O redirection in the building
     83    system of some packages to function properly:</para>
     84
     85<screen><userinput>ln -sfv /proc/self/fd/0 /dev/stdin
     86ln -sfv /proc/self/fd/1 /dev/stdout
     87ln -sfv /proc/self/fd/2 /dev/stderr
     88ln -sv  /proc/self/fd   /dev</userinput></screen>
    11889
    11990  </sect2>
Note: See TracChangeset for help on using the changeset viewer.