2020-06-07 21:16:00 +01:00
|
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
|
|
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
|
|
|
<!ENTITY % general-entities SYSTEM "../general.ent">
|
|
|
|
%general-entities;
|
|
|
|
]>
|
|
|
|
|
|
|
|
<sect1 id="ch-tools-kernfs">
|
|
|
|
<?dbhtml filename="kernfs.html"?>
|
|
|
|
|
|
|
|
<title>Preparing Virtual Kernel File Systems</title>
|
|
|
|
|
|
|
|
<indexterm zone="ch-tools-kernfs">
|
|
|
|
<primary sortas="e-/dev/">/dev/*</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
2022-09-30 18:27:55 +01:00
|
|
|
<para>Applications running in user space utilize various file
|
|
|
|
systems exported by the kernel to communicate
|
|
|
|
with the kernel itself. These file systems are virtual: no disk
|
2020-06-07 21:16:00 +01:00
|
|
|
space is used for them. The content of the file systems resides in
|
2022-09-30 18:27:55 +01:00
|
|
|
memory. These file systems must exist in the $LFS directory tree
|
|
|
|
before you can <command>chroot</command> successfully.</para>
|
2020-06-07 21:16:00 +01:00
|
|
|
|
2022-09-30 18:27:55 +01:00
|
|
|
<para>Begin by creating directories on which the file systems will be
|
2020-06-07 21:16:00 +01:00
|
|
|
mounted:</para>
|
|
|
|
|
|
|
|
<screen><userinput>mkdir -pv $LFS/{dev,proc,sys,run}</userinput></screen>
|
|
|
|
|
2020-06-22 21:51:45 +01:00
|
|
|
<sect2 id="ch-tools-bindmount">
|
2020-06-07 21:16:00 +01:00
|
|
|
<title>Mounting and Populating /dev</title>
|
|
|
|
|
2022-03-07 17:19:06 +00:00
|
|
|
<para>During a normal boot, the kernel automatically mounts the
|
|
|
|
<systemitem class="filesystem">devtmpfs</systemitem> filesystem on the
|
2022-09-30 18:27:55 +01:00
|
|
|
<filename class="directory">/dev</filename> directory; the
|
|
|
|
devices are created dynamically on that virtual filesystem when they
|
|
|
|
are first detected or accessed. Device creation is generally done during the
|
|
|
|
boot process by the kernel and the udev program.
|
|
|
|
Since the new system does not yet include udev and
|
2022-03-07 17:19:06 +00:00
|
|
|
has not yet been booted, it is necessary to mount and populate
|
2022-09-30 18:27:55 +01:00
|
|
|
the <filename class="directory">/dev</filename> directory manually. This is
|
2022-03-07 17:19:06 +00:00
|
|
|
accomplished by bind mounting the host system's
|
|
|
|
<filename class="directory">/dev</filename> directory. A bind mount is
|
|
|
|
a special type of mount that allows you to create a mirror of a
|
2022-09-30 18:27:55 +01:00
|
|
|
directory or mount point at some other location. Use the following
|
|
|
|
command to do this:</para>
|
2020-06-07 21:16:00 +01:00
|
|
|
|
|
|
|
<screen><userinput>mount -v --bind /dev $LFS/dev</userinput></screen>
|
|
|
|
|
|
|
|
</sect2>
|
|
|
|
|
2020-06-22 21:51:45 +01:00
|
|
|
<sect2 id="ch-tools-kernfsmount">
|
2020-06-07 21:16:00 +01:00
|
|
|
<title>Mounting Virtual Kernel File Systems</title>
|
|
|
|
|
|
|
|
<para>Now mount the remaining virtual kernel filesystems:</para>
|
|
|
|
|
|
|
|
<screen><userinput>mount -v --bind /dev/pts $LFS/dev/pts
|
|
|
|
mount -vt proc proc $LFS/proc
|
|
|
|
mount -vt sysfs sysfs $LFS/sys
|
|
|
|
mount -vt tmpfs tmpfs $LFS/run</userinput></screen>
|
2020-06-11 04:13:43 +01:00
|
|
|
<!--
|
2020-06-07 21:16:00 +01:00
|
|
|
<variablelist>
|
|
|
|
<title>The meaning of the mount options for devpts:</title>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>gid=5</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>This ensures that all devpts-created device nodes are owned by
|
|
|
|
group ID 5. This is the ID we will use later on for the <systemitem
|
|
|
|
class="groupname">tty</systemitem> group. We use the group ID instead
|
|
|
|
of a name, since the host system might use a different ID for its
|
|
|
|
<systemitem class="groupname">tty</systemitem> group.</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>mode=0620</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>This ensures that all devpts-created device nodes have mode 0620
|
|
|
|
(user readable and writable, group writable). Together with the
|
|
|
|
option above, this ensures that devpts will create device nodes that
|
|
|
|
meet the requirements of grantpt(), meaning the Glibc
|
|
|
|
<command>pt_chown</command> helper binary (which is not installed by
|
|
|
|
default) is not necessary.</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
</variablelist>
|
2020-06-11 04:13:43 +01:00
|
|
|
-->
|
2020-06-07 21:16:00 +01:00
|
|
|
<para>In some host systems, <filename>/dev/shm</filename> is a
|
|
|
|
symbolic link to <filename class="directory">/run/shm</filename>.
|
2021-09-07 21:35:55 +01:00
|
|
|
The /run tmpfs was mounted above so in this case only a
|
2020-06-07 21:16:00 +01:00
|
|
|
directory needs to be created.</para>
|
|
|
|
|
2022-09-30 18:27:55 +01:00
|
|
|
<para>In other host systems <filename>/dev/shm</filename> is a mount point
|
2022-09-20 18:20:58 +01:00
|
|
|
for a tmpfs. In that case the mount of /dev above will only create
|
2022-09-30 18:27:55 +01:00
|
|
|
/dev/shm as a directory in the chroot environment. In this situation
|
|
|
|
we must explicitly mount a tmpfs:</para>
|
2022-09-20 18:20:58 +01:00
|
|
|
|
2020-06-07 21:16:00 +01:00
|
|
|
<screen><userinput>if [ -h $LFS/dev/shm ]; then
|
|
|
|
mkdir -pv $LFS/$(readlink $LFS/dev/shm)
|
2022-09-20 18:20:58 +01:00
|
|
|
else
|
|
|
|
mount -t tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm
|
2020-06-07 21:16:00 +01:00
|
|
|
fi</userinput></screen>
|
|
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
|
|
</sect1>
|