[9dfc02f] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[b06ca36] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[81fd230] | 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
[bdea25ce] | 7 |
|
---|
[9dfc02f] | 8 | <sect1 id="ch-system-kernfs">
|
---|
[bdea25ce] | 9 | <?dbhtml filename="kernfs.html"?>
|
---|
| 10 |
|
---|
[d2c332bc] | 11 | <title>Preparing Virtual Kernel File Systems</title>
|
---|
[9dfc02f] | 12 |
|
---|
[d2c332bc] | 13 | <indexterm zone="ch-system-kernfs">
|
---|
| 14 | <primary sortas="e-/dev/">/dev/*</primary>
|
---|
| 15 | </indexterm>
|
---|
[81fd230] | 16 |
|
---|
[d2c332bc] | 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>
|
---|
[9dfc02f] | 21 |
|
---|
[d2c332bc] | 22 | <para>Begin by creating directories onto which the file systems will be
|
---|
| 23 | mounted:</para>
|
---|
[9dfc02f] | 24 |
|
---|
[7f35c7f] | 25 | <screen><userinput>mkdir -v $LFS/{dev,proc,sys}</userinput></screen>
|
---|
[9dfc02f] | 26 |
|
---|
[d2c332bc] | 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
|
---|
[41ab793] | 33 | class="devicefile">null</filename> devices. The device nodes must be created
|
---|
[a0d96d25] | 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
|
---|
[d2c332bc] | 37 | following commands:</para>
|
---|
| 38 |
|
---|
| 39 | <screen><userinput>mknod -m 600 $LFS/dev/console c 5 1
|
---|
| 40 | mknod -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>
|
---|
[9dfc02f] | 46 |
|
---|
[d2c332bc] | 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
|
---|
[50afc7c] | 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
|
---|
[d2c332bc] | 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>
|
---|
[81fd230] | 61 |
|
---|
[79286f58] | 62 | <screen><userinput>mount -v --bind /dev $LFS/dev</userinput></screen>
|
---|
[d2c332bc] | 63 |
|
---|
| 64 | </sect2>
|
---|
[c226182] | 65 |
|
---|
[d2c332bc] | 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 -vt devpts devpts $LFS/dev/pts
|
---|
| 72 | mount -vt proc proc $LFS/proc
|
---|
| 73 | mount -vt sysfs sysfs $LFS/sys</userinput></screen>
|
---|
[9dfc02f] | 74 |
|
---|
[40690e1] | 75 | <para>In some host systems, <filename>/dev/shm</filename> is a
|
---|
| 76 | symbolic link to <filename class="directory">/run/shm</filename>.
|
---|
[409e7c8] | 77 | Inside a chroot environment, this temporary file system needs
|
---|
| 78 | to be mounted separate from the host file system:</para>
|
---|
| 79 |
|
---|
| 80 | <screen><userinput>if [ -h $LFS/dev/shm ]; then
|
---|
| 81 | link=$(readlink $LFS/dev/shm)
|
---|
| 82 | mkdir -p $LFS/$link
|
---|
| 83 | mount -vt tmpfs shm $LFS/$link
|
---|
| 84 | unset link
|
---|
| 85 | else
|
---|
| 86 | mount -vt tmpfs shm $LFS/dev/shm
|
---|
| 87 | fi</userinput></screen>
|
---|
[40690e1] | 88 |
|
---|
[d2c332bc] | 89 | </sect2>
|
---|
[9dfc02f] | 90 |
|
---|
| 91 | </sect1>
|
---|