source: chapter07/kernfs.xml@ 387a32af

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 ml-11.0 multilib trunk xry111/git-transition xry111/glibc-2.34 xry111/tester-nohack xry111/usr-move
Last change on this file since 387a32af was 387a32af, checked in by Bruce Dubbs <bdubbs@…>, 18 months ago

Update initial Chapter 7 pages for cross2 branch

git-svn-id: 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 4.6 KB
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
8<sect1 id="ch-tools-kernfs">
9 <?dbhtml filename="kernfs.html"?>
11 <title>Preparing Virtual Kernel File Systems</title>
13 <indexterm zone="ch-tools-kernfs">
14 <primary sortas="e-/dev/">/dev/*</primary>
15 </indexterm>
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>
22 <para>Begin by creating directories onto which the file systems will be
23 mounted:</para>
25<screen><userinput>mkdir -pv $LFS/{dev,proc,sys,run}</userinput></screen>
27 <sect2>
28 <title>Creating Initial Device Nodes</title>
30 <para>When the kernel boots the system, it requires the presence of a few
31 device nodes, in particular the <filename
32 class="devicefile">console</filename> and <filename
33 class="devicefile">null</filename> devices. The device nodes must be
34 created on the hard disk so that they are available before the kernel
35 populates <systemitem class="filesystem">/dev</systemitem>), and
36 additionally when Linux is started with
37 <parameter>init=/bin/bash</parameter>. Create the devices by running the
38 following commands:</para>
40<screen><userinput>mknod -m 600 $LFS/dev/console c 5 1
41mknod -m 666 $LFS/dev/null c 1 3</userinput></screen>
43 </sect2>
45 <sect2 id="ch-system-bindmount">
46 <title>Mounting and Populating /dev</title>
48 <para>The recommended method of populating the <filename
49 class="directory">/dev</filename> directory with devices is to mount a
50 virtual filesystem (such as <systemitem
51 class="filesystem">tmpfs</systemitem>) on the <filename
52 class="directory">/dev</filename> directory, and allow the devices to be
53 created dynamically on that virtual filesystem as they are detected or
54 accessed. Device creation is generally done during the boot process
55 by Udev. Since this new system does not yet have Udev and has not yet
56 been booted, it is necessary to mount and populate <filename
57 class="directory">/dev</filename> manually. This is accomplished by bind
58 mounting the host system's <filename class="directory">/dev</filename>
59 directory. A bind mount is a special type of mount that allows you to
60 create a mirror of a directory or mount point to some other location. Use
61 the following command to achieve this:</para>
63<screen><userinput>mount -v --bind /dev $LFS/dev</userinput></screen>
65 </sect2>
67 <sect2 id="ch-system-kernfsmount">
68 <title>Mounting Virtual Kernel File Systems</title>
70 <para>Now mount the remaining virtual kernel filesystems:</para>
72<screen><userinput>mount -v --bind /dev/pts $LFS/dev/pts
73mount -vt proc proc $LFS/proc
74mount -vt sysfs sysfs $LFS/sys
75mount -vt tmpfs tmpfs $LFS/run</userinput></screen>
77 <variablelist>
78 <title>The meaning of the mount options for devpts:</title>
80 <varlistentry>
81 <term><parameter>gid=5</parameter></term>
82 <listitem>
83 <para>This ensures that all devpts-created device nodes are owned by
84 group ID 5. This is the ID we will use later on for the <systemitem
85 class="groupname">tty</systemitem> group. We use the group ID instead
86 of a name, since the host system might use a different ID for its
87 <systemitem class="groupname">tty</systemitem> group.</para>
88 </listitem>
89 </varlistentry>
91 <varlistentry>
92 <term><parameter>mode=0620</parameter></term>
93 <listitem>
94 <para>This ensures that all devpts-created device nodes have mode 0620
95 (user readable and writable, group writable). Together with the
96 option above, this ensures that devpts will create device nodes that
97 meet the requirements of grantpt(), meaning the Glibc
98 <command>pt_chown</command> helper binary (which is not installed by
99 default) is not necessary.</para>
100 </listitem>
101 </varlistentry>
103 </variablelist>
105 <para>In some host systems, <filename>/dev/shm</filename> is a
106 symbolic link to <filename class="directory">/run/shm</filename>.
107 The /run tmpfs was mounted above so in this case only a
108 directory needs to be created.</para>
110<screen><userinput>if [ -h $LFS/dev/shm ]; then
111 mkdir -pv $LFS/$(readlink $LFS/dev/shm)
114 </sect2>
Note: See TracBrowser for help on using the repository browser.