|
@@ -8,33 +8,44 @@
|
|
|
<sect1 id="ch-system-kernfs">
|
|
|
<?dbhtml filename="kernfs.html"?>
|
|
|
|
|
|
- <title>Preparing Virtual Kernel File Systems</title>
|
|
|
+ <title>准备虚拟内核文件系统</title>
|
|
|
|
|
|
<indexterm zone="ch-system-kernfs">
|
|
|
<primary sortas="e-/dev/">/dev/*</primary>
|
|
|
</indexterm>
|
|
|
|
|
|
- <para>Various file systems exported by the kernel are used to communicate to
|
|
|
+ <!--para>Various file systems exported by the kernel are used to communicate to
|
|
|
and from the kernel itself. These file systems are virtual in that no disk
|
|
|
space is used for them. The content of the file systems resides in
|
|
|
- memory.</para>
|
|
|
+ memory.</para-->
|
|
|
+ <para>内核对外提供了一些文件系统,以便自己和用户空间进行通信。
|
|
|
+ 它们是虚拟文件系统,并不占用磁盘空间,其内容保留在内存中。
|
|
|
+ </para>
|
|
|
|
|
|
- <para>Begin by creating directories onto which the file systems will be
|
|
|
- mounted:</para>
|
|
|
+ <!--para>Begin by creating directories onto which the file systems will be
|
|
|
+ mounted:</para-->
|
|
|
+ <para>首先创建用来挂载这些文件系统的目录:</para>
|
|
|
|
|
|
<screen><userinput>mkdir -pv $LFS/{dev,proc,sys,run}</userinput></screen>
|
|
|
|
|
|
<sect2>
|
|
|
- <title>Creating Initial Device Nodes</title>
|
|
|
+ <title>创建初始设备节点</title>
|
|
|
|
|
|
- <para>When the kernel boots the system, it requires the presence of a few
|
|
|
+ <!--para>When the kernel boots the system, it requires the presence of a few
|
|
|
device nodes, in particular the <filename
|
|
|
class="devicefile">console</filename> and <filename
|
|
|
class="devicefile">null</filename> devices. The device nodes must be created
|
|
|
on the hard disk so that they are available before <command>udevd</command>
|
|
|
has been started, and additionally when Linux is started with
|
|
|
<parameter>init=/bin/bash</parameter>. Create the devices by running the
|
|
|
- following commands:</para>
|
|
|
+ following commands:</para-->
|
|
|
+ <para>在内核引导系统时,它需要一些设备节点,特别是
|
|
|
+ <filename class="devicefile">console</filename>
|
|
|
+ 和 <filename class="devicefile">null</filename> 两个设备。
|
|
|
+ 它们需要创建在硬盘上,这样在 <command>udevd</command>
|
|
|
+ 启动前即可使用,特别是在 Linux 使用
|
|
|
+ <parameter>init=/bin/bash</parameter> 内核选项启动的时候。
|
|
|
+ 运行下列命令创建它们:</para>
|
|
|
|
|
|
<screen><userinput>mknod -m 600 $LFS/dev/console c 5 1
|
|
|
mknod -m 666 $LFS/dev/null c 1 3</userinput></screen>
|
|
@@ -42,9 +53,9 @@ mknod -m 666 $LFS/dev/null c 1 3</userinput></screen>
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 id="ch-system-bindmount">
|
|
|
- <title>Mounting and Populating /dev</title>
|
|
|
+ <title>挂载和填充 /dev</title>
|
|
|
|
|
|
- <para>The recommended method of populating the <filename
|
|
|
+ <!--para>The recommended method of populating the <filename
|
|
|
class="directory">/dev</filename> directory with devices is to mount a
|
|
|
virtual filesystem (such as <systemitem
|
|
|
class="filesystem">tmpfs</systemitem>) on the <filename
|
|
@@ -57,16 +68,28 @@ mknod -m 666 $LFS/dev/null c 1 3</userinput></screen>
|
|
|
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 directory or mount point to some other location. Use
|
|
|
- the following command to achieve this:</para>
|
|
|
+ the following command to achieve this:</para-->
|
|
|
+ <para>用设备文件填充 <filename class="directory">/dev</filename>
|
|
|
+ 目录的推荐方法是挂载一个虚拟文件系统(例如
|
|
|
+ <systemitem class="filesystem">tmpfs</systemitem>),
|
|
|
+ 然后在设备被发现或访问时动态地创建设备文件。
|
|
|
+ 这个工作通常由 Udev 在系统引导时完成,但我们的新系统还没有 Udev,
|
|
|
+ 也没有被引导过,因此必须手工挂载和填充
|
|
|
+ <filename class="directory">/dev</filename>。
|
|
|
+ 这通过绑定挂载宿主系统的
|
|
|
+ <filename class="directory">/dev</filename>
|
|
|
+ 目录就可以实现,绑定挂载是一种特殊挂载类型,
|
|
|
+ 它允许在另外的位置创建某个目录或挂载点的映像。
|
|
|
+ 运行下列命令进行绑定挂载:</para>
|
|
|
|
|
|
<screen><userinput>mount -v --bind /dev $LFS/dev</userinput></screen>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 id="ch-system-kernfsmount">
|
|
|
- <title>Mounting Virtual Kernel File Systems</title>
|
|
|
+ <title>挂载虚拟内核文件系统</title>
|
|
|
|
|
|
- <para>Now mount the remaining virtual kernel filesystems:</para>
|
|
|
+ <para>现在挂载剩余的虚拟内核文件系统:</para>
|
|
|
|
|
|
<screen><userinput>mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620
|
|
|
mount -vt proc proc $LFS/proc
|
|
@@ -74,37 +97,51 @@ mount -vt sysfs sysfs $LFS/sys
|
|
|
mount -vt tmpfs tmpfs $LFS/run</userinput></screen>
|
|
|
|
|
|
<variablelist>
|
|
|
- <title>The meaning of the mount options for devpts:</title>
|
|
|
+ <title>devpts 挂载选项的含义:</title>
|
|
|
|
|
|
<varlistentry>
|
|
|
<term><parameter>gid=5</parameter></term>
|
|
|
<listitem>
|
|
|
- <para>This ensures that all devpts-created device nodes are owned by
|
|
|
+ <!--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>
|
|
|
+ <systemitem class="groupname">tty</systemitem> group.</para-->
|
|
|
+ <para>这保证 devpts 创建的所有设备节点都属于 ID 为 5 的组,
|
|
|
+ 我们之后会把这个 ID 分配给 <systemitem class="groupname">
|
|
|
+ tty</systemitem> 组。这里使用组 ID 而不是名称,
|
|
|
+ 因为宿主系统的 <systemitem class="groupname">tty</systemitem>
|
|
|
+ 组可能有不同的 ID 。</para>
|
|
|
</listitem>
|
|
|
</varlistentry>
|
|
|
|
|
|
<varlistentry>
|
|
|
<term><parameter>mode=0620</parameter></term>
|
|
|
<listitem>
|
|
|
- <para>This ensures that all devpts-created device nodes have mode 0620
|
|
|
+ <!--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>
|
|
|
+ default) is not necessary.</para-->
|
|
|
+ <para>该选项确保 devpts 创建的所有设备节点具有访问权限 0620
|
|
|
+ (所有者可读写,组成员可写)。与上一个选项结合使用,
|
|
|
+ 可以保证 devpts 创建符合 grantpt() 要求的设备节点,
|
|
|
+ 摆脱对 Glibc <command>pt_chown</command> 辅助程序
|
|
|
+ (默认不安装)的需要。</para>
|
|
|
</listitem>
|
|
|
</varlistentry>
|
|
|
|
|
|
</variablelist>
|
|
|
|
|
|
- <para>In some host systems, <filename>/dev/shm</filename> is a
|
|
|
+ <!--para>In some host systems, <filename>/dev/shm</filename> is a
|
|
|
symbolic link to <filename class="directory">/run/shm</filename>.
|
|
|
The /run tmpfs was mounted above so in this case only a
|
|
|
- directory needs to be created.</para>
|
|
|
+ directory needs to be created.</para-->
|
|
|
+ <para>在某些宿主系统上,<filename>/dev/shm</filename>
|
|
|
+ 是一个指向 <filename class="directory">/run/shm</filename>
|
|
|
+ 的符号链接。我们已经在 /run 下挂载了 tmpfs 文件系统,
|
|
|
+ 因此在这里只需要创建一个目录。</para>
|
|
|
|
|
|
<screen><userinput>if [ -h $LFS/dev/shm ]; then
|
|
|
mkdir -pv $LFS/$(readlink $LFS/dev/shm)
|