source: chapter07/kernfs.xml@ fcc02767

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 fcc02767 was fcc02767, checked in by Bruce Dubbs <bdubbs@…>, 18 months ago

Initial commit of alternative cross LFS

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/cross2@11897 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 4.5 KB
Line 
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
27 <sect2>
28 <title>Creating Initial Device Nodes</title>
29
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 created
34 on the hard disk so that they are available before <command>udevd</command>
35 has been started, and additionally when Linux is started with
36 <parameter>init=/bin/bash</parameter>. Create the devices by running the
37 following commands:</para>
38
39<screen><userinput>mknod -m 600 $LFS/dev/console c 5 1
40mknod -m 666 $LFS/dev/null c 1 3</userinput></screen>
41
42 </sect2>
43
44 <sect2 id="ch-system-bindmount">
45 <title>Mounting and Populating /dev</title>
46
47 <para>The recommended method of populating the <filename
48 class="directory">/dev</filename> directory with devices is to mount a
49 virtual filesystem (such as <systemitem
50 class="filesystem">tmpfs</systemitem>) on the <filename
51 class="directory">/dev</filename> directory, and allow the devices to be
52 created dynamically on that virtual filesystem as they are detected or
53 accessed. Device creation is generally done during the boot process
54 by Udev. Since this new system does not yet have Udev and has not yet
55 been booted, it is necessary to mount and populate <filename
56 class="directory">/dev</filename> manually. This is accomplished by bind
57 mounting the host system's <filename class="directory">/dev</filename>
58 directory. A bind mount is a special type of mount that allows you to
59 create a mirror of a directory or mount point to some other location. Use
60 the following command to achieve this:</para>
61
62<screen><userinput>mount -v --bind /dev $LFS/dev</userinput></screen>
63
64 </sect2>
65
66 <sect2 id="ch-system-kernfsmount">
67 <title>Mounting Virtual Kernel File Systems</title>
68
69 <para>Now mount the remaining virtual kernel filesystems:</para>
70
71<screen><userinput>mount -v --bind /dev/pts $LFS/dev/pts
72mount -vt proc proc $LFS/proc
73mount -vt sysfs sysfs $LFS/sys
74mount -vt tmpfs tmpfs $LFS/run</userinput></screen>
75
76 <variablelist>
77 <title>The meaning of the mount options for devpts:</title>
78
79 <varlistentry>
80 <term><parameter>gid=5</parameter></term>
81 <listitem>
82 <para>This ensures that all devpts-created device nodes are owned by
83 group ID 5. This is the ID we will use later on for the <systemitem
84 class="groupname">tty</systemitem> group. We use the group ID instead
85 of a name, since the host system might use a different ID for its
86 <systemitem class="groupname">tty</systemitem> group.</para>
87 </listitem>
88 </varlistentry>
89
90 <varlistentry>
91 <term><parameter>mode=0620</parameter></term>
92 <listitem>
93 <para>This ensures that all devpts-created device nodes have mode 0620
94 (user readable and writable, group writable). Together with the
95 option above, this ensures that devpts will create device nodes that
96 meet the requirements of grantpt(), meaning the Glibc
97 <command>pt_chown</command> helper binary (which is not installed by
98 default) is not necessary.</para>
99 </listitem>
100 </varlistentry>
101
102 </variablelist>
103
104 <para>In some host systems, <filename>/dev/shm</filename> is a
105 symbolic link to <filename class="directory">/run/shm</filename>.
106 The /run tmpfs was mounted above so in this case only a
107 directory needs to be created.</para>
108
109<screen><userinput>if [ -h $LFS/dev/shm ]; then
110 mkdir -pv $LFS/$(readlink $LFS/dev/shm)
111fi</userinput></screen>
112
113 </sect2>
114
115</sect1>
Note: See TracBrowser for help on using the repository browser.