Changes in chapter07/kernfs.xml [2bf32ff:d963661]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter07/kernfs.xml
r2bf32ff rd963661 19 19 with the kernel itself. These file systems are virtual: no disk 20 20 space is used for them. The content of the 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> 23 22 24 23 <para>Begin by creating directories on which the file systems will be 25 24 mounted:</para> 26 25 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 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 36 creates device nodes on that virtual filesystem during the boot process 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 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 55 directory or mount point at some other location. Use the following 56 command to do this:</para> 57 58 <screen><userinput>mount -v --bind /dev $LFS/dev</userinput></screen> 59 60 </sect2> 26 <screen><userinput>mkdir -pv /{proc,sys,run}</userinput></screen> 61 27 62 28 <sect2 id="ch-tools-kernfsmount"> 63 29 <title>Mounting Virtual Kernel File Systems</title> 64 30 65 <para>Now mount the remaining virtual kernel filesystems:</para> 31 <para>The kernel has already mounted 32 <systemitem class="filesystem">devtmpfs</systemitem>. 33 Mount the remaining virtual kernel filesystems:</para> 66 34 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> 71 <!-- 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 40 mount -vt tmpfs tmpfs /dev/shm -o nosuid,nodev</userinput></screen> 41 72 42 <variablelist> 73 43 <title>The meaning of the mount options for devpts:</title> … … 97 67 98 68 </variablelist> 99 -->100 <para>In some host systems, <filename>/dev/shm</filename> is a101 symbolic link to <filename class="directory">/run/shm</filename>.102 The /run tmpfs was mounted above so in this case only a103 directory needs to be created.</para>104 69 105 <para>In other host systems <filename>/dev/shm</filename> is a mount point 106 for a tmpfs. In that case the mount of /dev above will only create 107 /dev/shm as a directory in the chroot environment. In this situation 108 we must explicitly mount a tmpfs:</para> 70 </sect2> 109 71 110 <screen><userinput>if [ -h $LFS/dev/shm ]; then 111 mkdir -pv $LFS/$(readlink $LFS/dev/shm) 112 else 113 mount -t tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm 114 fi</userinput></screen> 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 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> 83 84 <screen><userinput>ln -sfv /proc/self/fd/0 /dev/stdin 85 ln -sfv /proc/self/fd/1 /dev/stdout 86 ln -sfv /proc/self/fd/2 /dev/stderr 87 ln -sv /proc/self/fd /dev</userinput></screen> 115 88 116 89 </sect2>
Note:
See TracChangeset
for help on using the changeset viewer.