浏览代码

chapter07: Translate device management page (symlink.xml) for sysv

Xi Ruoyao 7 年之前
父节点
当前提交
f60de70ed1
共有 1 个文件被更改,包括 144 次插入82 次删除
  1. 144 82
      chapter07/symlinks.xml

+ 144 - 82
chapter07/symlinks.xml

@@ -12,57 +12,73 @@
 
   <sect2 revision="sysv">
 
-    <title>Network Devices</title>
+    <title>网络设备</title>
 
-    <para>Udev, by default, names network devices according to Firmware/BIOS
+    <!--para>Udev, by default, names network devices according to Firmware/BIOS
     data or physical characteristics like the bus, slot, or MAC address.  The
     purpose of this naming convention is to ensure that network devices are
     named consistently and not based on the time the network card was
     discovered.  For example, on a computer having two network cards made by
     Intel and Realtek, the network card manufactured by Intel may become eth0
     and the Realtek card becomes eth1. In some cases, after a reboot the cards
-    get renumbered the other way around.</para>
+    get renumbered the other way around.</para-->
+    <para>Udev 在默认情况下,根据固件与 BIOS 的数据,或总线、插槽与 MAC 地址
+		等物理特性命名网络设备。
+		这种命名法的主要目的是保证网络设备在每次引导时获得一致的命名,
+		而不是基于网卡被系统发现的时间进行命名。
+		例如,在老式命名方法中,如果一台计算机拥有两块网卡,
+		其中一块由 Intel 生产,另一块由 Realtek 生产,
+		则 Intel 网卡可能被命名为 eth0 ,而 Realtek 网卡被命名为 eth1,
+		然而在重新启动系统后,它们的顺序可能会颠倒。</para>
     
-    <para>In the new naming scheme, typical network device names would then
+    <!--para>In the new naming scheme, typical network device names would then
     be something like enp5s0 or wlp3s0.  If this naming convention is not
     desired, the traditional naming scheme or a custom scheme can be
-    implemented.</para>
+    implemented.</para-->
+    <para>在新的命名架构中,典型的网络设备名称就像 enp5s0 或 wlp3s0 这样。
+		如果您不喜欢这种命名惯例,可以采用传统或自定义命名架构。</para>
 
     <sect3>
-      <title>Disabling Persistent Naming on the Kernel Command Line</title>
+      <title>在内核命令行中禁用一致性命名</title>
    
-      <para>The traditional naming scheme using eth0, eth1, etc can be
-      restored by adding <userinput>net.ifnames=0</userinput> on the 
-      kernel command line.  This is most appropriate for those systems
-      that have only one ethernet device of the same type.  Laptops
-      often have multiple ethernet connections that are named eth0 and 
-      wlan0 and are also candidates for this method.  The command line 
-      is passed in the GRUB configuration file. 
-      See <xref linkend="grub-cfg"/>.</para>
+      <para>传统的,如同 eth0,eth1 这样的命名架构可以通过在内核命令行中加入
+      <userinput>net.ifnames=0</userinput> 而恢复。
+	  这在那些没有两块同类以太网设备的机器上最为合适。
+	  笔记本一般拥有两个以太网连接,在这种命名方式下分别是
+	  eth0 和 wlan0,也可以采用这种方法。
+	  内核命令行需要写入 GRUB 配置文件中,参阅
+      <xref linkend="grub-cfg"/>。</para>
     </sect3>
 
     <sect3>
-      <title>Creating Custom Udev Rules</title>
+      <title>创建自定义 Udev 规则</title>
    
-      <para>The naming scheme can be customized by creating custom Udev
+      <!--para>The naming scheme can be customized by creating custom Udev
       rules.  A script has been included that generates the initial rules.
-      Generate these rules by running:</para>
+      Generate these rules by running:</para-->
+      <para>可以创建自定义 Udev 规则,定制命名架构。
+		  系统中包含一个生成初始规则的脚本,执行下列命令生成初始规则:
+	  </para>
 
 <screen role="install"><userinput>bash /lib/udev/init-net-rules.sh</userinput></screen>
 
-      <para> Now, inspect the
-      <filename>/etc/udev/rules.d/70-persistent-net.rules</filename> file, to
-      find out which name was assigned to which network device:</para>
+      <para> 现在检查文件
+      <filename>/etc/udev/rules.d/70-persistent-net.rules</filename>
+      确认网络设备与命名的对应关系:</para>
 
 <screen role="nodump"><userinput>cat /etc/udev/rules.d/70-persistent-net.rules</userinput></screen>
 
-      <note><para>In some cases such as when MAC addresses have been assigned to
+      <note><!--para>In some cases such as when MAC addresses have been assigned to
       a network card manually or in a virtual environment such as Qemu or Xen,
       the network rules file may not have been generated because addresses
       are not consistently assigned.  In these cases, this method cannot
-      be used.</para></note>
+	  be used.</para-->
+      <para>某些情况下,例如 MAC 地址被手动指定给了某块网卡,或在 Qemu、
+		  Xen 等虚拟环境下,可能不会生成网络设备规则文件,
+		  因为 MAC 地址的分配没有一致性。此时不能使用本方法。</para>
+	  </note>
   
-      <para>The file begins with a comment block followed by two lines for each
+      <!--para>The file begins with a comment block followed by two lines for each
       NIC. The first line for each NIC is a commented description showing its
       hardware IDs (e.g. its PCI vendor and device IDs, if it's a PCI card),
       along with its driver in parentheses, if the driver can be found. Neither
@@ -72,45 +88,51 @@
   
       <para>All Udev rules are made up of several keys, separated by commas and
       optional whitespace. This rule's keys and an explanation of each of them
-      are as follows:</para>
+      are as follows:</para-->
+      <para>该文件的开头是一个注释块,之后对于每个网络接口设备(NIC)
+		  都给出两行,第一行是注释,给出该 NIC 的硬件 ID (例如它的
+		  PCI 生产商 ID 和设备 ID,如果它是 PCI 设备的话),
+		  并在括号中给出它的驱动程序,如果能找到驱动程序的话。
+		  它们并不被用于确定该设备的命名,仅供您在编写规则时进行参考。
+		  第二行是匹配该 NIC 的 udev 规则,和实际赋予它的设备名。</para>
+	  <para>所有 udev 规则包含若干键值,用逗号和可选的空格进行分隔。
+		  下面给出规则中包含的键值和对它们的解释:</para>
   
       <itemizedlist>
         <listitem>
-          <para><literal>SUBSYSTEM=="net"</literal> - This tells Udev to ignore
-          devices that are not network cards.</para>
+          <para><literal>SUBSYSTEM=="net"</literal> -
+          告诉 udev 忽略除网卡以外的设备。</para>
         </listitem>
         <listitem>
-          <para><literal>ACTION=="add"</literal> - This tells Udev to ignore this
-          rule for a uevent that isn't an add ("remove" and "change" uevents also
-          happen, but don't need to rename network interfaces).</para>
+          <para><literal>ACTION=="add"</literal> -
+			  告诉 udev 忽略除了<quote>添加</quote>外的所有 uevent
+			  (也存在<quote>删除</quote>或<quote>修改</quote>类型的
+			  uevent,但在这种情况下不需要重命名网络接口。</para>
         </listitem>
         <listitem>
-          <para><literal>DRIVERS=="?*"</literal> - This exists so that Udev will
-          ignore VLAN or bridge sub-interfaces (because these sub-interfaces do
-          not have drivers). These sub-interfaces are skipped because the name
-          that would be assigned would collide with their parent devices.</para>
+          <para><literal>DRIVERS=="?*"</literal> -
+          这使得 udev 忽略 VLAN 或桥接子接口(它们没有驱动程序)。
+          它们必须被忽略,否则其命名会与父设备冲突。</para>
         </listitem>
         <listitem>
-          <para><literal>ATTR{address}</literal> - The value of this key is the
-          NIC's MAC address.</para>
+          <para><literal>ATTR{address}</literal> -
+          该键的值是 NIC 的 MAC 地址。</para>
         </listitem>
         <listitem>
-          <para><literal>ATTR{type}=="1"</literal> - This ensures the rule only
-          matches the primary interface in the case of certain wireless drivers,
-          which create multiple virtual interfaces. The secondary interfaces are
-          skipped for the same reason that VLAN and bridge sub-interfaces are
-          skipped: there would be a name collision otherwise.</para>
+          <para><literal>ATTR{type}=="1"</literal> -
+          这保证在使用创建多个虚拟接口的无线驱动程序时,
+		  只匹配主要接口。跳过其他接口的原因和忽略 VLAN 与桥接子接口一样,
+		  是为了防止命名冲突。</para>
         </listitem>
         <listitem>
-          <para><literal>NAME</literal> - The value of this key is the name that
-          Udev will assign to this interface.</para>
+          <para><literal>NAME</literal> -
+          该键的值是 udev 将赋予该网络接口的命名</para>
         </listitem>
       </itemizedlist>
   
-      <para>The value of <literal>NAME</literal> is the important part. Make sure
-      you know which name has been assigned to each of your network cards before
-      proceeding, and be sure to use that <literal>NAME</literal> value when
-      creating your configuration files below.</para>
+      <para><literal>NAME</literal> 的值是我们关注的重点。
+      您在继续阅读之前,需要确保自己知道赋予每个网络接口的命名,
+      在之后的配置文件中需要使用这些名称。</para>
 
     </sect3>
 
@@ -118,18 +140,27 @@
 
   <sect2 revision="sysv">
 
-    <title>CD-ROM symlinks</title>
+    <title>CD-ROM 符号链接</title>
 
-    <para>Some software that you may want to install later (e.g., various
+    <!--para>Some software that you may want to install later (e.g., various
     media players) expect the <filename class="symlink">/dev/cdrom</filename>
     and <filename class="symlink">/dev/dvd</filename> symlinks to exist, and
     to point to a CD-ROM or DVD-ROM device. Also, it may be convenient to put
     references to those symlinks into <filename>/etc/fstab</filename>. Udev
     comes with a script that will generate rules files to create these symlinks
     for you, depending on the capabilities of each device, but you need to
-    decide which of two modes of operation you wish to have the script use.</para>
-
-    <para>First, the script can operate in <quote>by-path</quote> mode (used by
+    decide which of two modes of operation you wish to have the script use.</para-->
+    <para>您之后可能希望安装的一些程序(如某些媒体播放器)预期
+		<filename class="symlink">/dev/cdrom</filename>
+		和 <filename class="symlink">/dev/dvd</filename>
+		符号链接存在,并指向 CD-ROM 或 DVD-ROM 设备。
+		另外,在 <filename>/etc/fstab</filename>
+		中引用它们也非常方便。Udev 提供了一个脚本,
+		能根据每个设备的功能,为您生成创建这两个符号链接的规则。
+		但是,您需要确定,自己希望使用该脚本提供的两种操作模式中的哪一种。
+	</para>
+
+    <!--para>First, the script can operate in <quote>by-path</quote> mode (used by
     default for USB and FireWire devices), where the rules it creates depend on
     the physical path to the CD or DVD device. Second, it can operate in
     <quote>by-id</quote> mode (default for IDE and SCSI devices), where the
@@ -137,9 +168,18 @@
     device itself. The path is determined by Udev's <command>path_id</command>
     script, and the identification strings are read from the hardware by its
     <command>ata_id</command> or <command>scsi_id</command> programs, depending
-    on which type of device you have.</para>
-
-    <para>There are advantages to each approach; the correct approach to use
+    on which type of device you have.</para-->
+    <para>首先,该脚本可以在 <quote>by-path</quote> 模式下运行
+		(这是 USB 和 FireWire 设备的默认模式),此时它创建的规则依赖于
+		CD 或 DVD 设备的物理路径。其次,它可以在 <quote>by-id</quote>
+		模式下运行,此时它创建的规则依赖于 CD 或 DVD
+		设备本身存储的识别字符串。物理路径由 udev 的
+		<command>path_id</command> 脚本确定,
+		而识别字符串由 <command>ata_id</command> 或
+		<command>scsi_id</command> 程序(根据设备类型选用其中一个)
+		从硬件中读取。</para>
+
+    <!--para>There are advantages to each approach; the correct approach to use
     will depend on what kinds of device changes may happen. If you expect the
     physical path to the device (that is, the ports and/or slots that it plugs
     into) to change, for example because you plan on moving the drive to a
@@ -148,57 +188,79 @@
     identification to change, for example because it may die, and you would
     replace it with a different device with the same capabilities and which
     is plugged into the same connectors, then you should use the
-    <quote>by-path</quote> mode.</para>
-
-    <para>If either type of change is possible with your drive, then choose a
-    mode based on the type of change you expect to happen more often.</para>
+    <quote>by-path</quote> mode.</para-->
+    <para>两种方式各有优缺点,正确地方式依赖于设备可能发生的变化。
+		如果您预期指向设备的物理路径(即它连接的端口或插槽)可能变化,
+		例如您可能会将它移动到另一个 IDE 接口或另一个 USB 接口,
+		您应该使用 <quote>by-id</quote> 模式。
+		另一方面,如果您可能用具有相同功能,
+		并接入相同接口的另一台设备替换它,则您应该使用
+		<quote>by-path</quote> 模式。</para>
+
+    <!--para>If either type of change is possible with your drive, then choose a
+    mode based on the type of change you expect to happen more often.</para-->
+    <para>如果两种变化都可能发生,则根据您预期较常发生的变化选择模式。
+    </para>
 
 <!-- If you use by-id mode, the symlinks will survive even the transition
      to libata for IDE drives, but that is not for the book. -->
 
-    <important><para>External devices (for example, a USB-connected CD drive)
+    <!--important><para>External devices (for example, a USB-connected CD drive)
     should not use by-path persistence, because each time the device is plugged
     into a new external port, its physical path will change. All
     externally-connected devices will have this problem if you write Udev rules
     to recognize them by their physical path; the problem is not limited to CD
-    and DVD drives.</para></important>
-
-    <para>If you wish to see the values that the Udev scripts will use, then
-    for the appropriate CD-ROM device, find the corresponding directory under
-    <filename class="directory">/sys</filename> (e.g., this can be
-    <filename class="directory">/sys/block/hdd</filename>) and
-    run a command similar to the following:</para>
+    and DVD drives.</para></important-->
+	<important>
+		<para>外接设备(例如 USB 接口的 CD 驱动器)不应使用 by-path 模式,
+			因为每次将该设备插入到新的外部接口时,其物理路径都会变化。
+			只要您使用了基于物理路径识别外接设备的 udev 规则,
+			都会导致这个问题,并不仅限于 CD 或 DVD 设备。
+		</para>
+	</important>
+
+	<para>如果您希望知道 udev 脚本会使用的路径或识别字符串值,
+    对于正确的 CD-ROM 驱动器,在
+    <filename class="directory">/sys</filename> 目录中找到对应的目录
+    (例如 <filename class="directory">/sys/block/hdd</filename>),
+    然后运行类似下面这样的命令:</para>
 
 <screen role="nodump"><userinput>udevadm test /sys/block/hdd</userinput></screen>
 
-    <para>Look at the lines containing the output of various *_id programs.
-    The <quote>by-id</quote> mode will use the ID_SERIAL value if it exists and
-    is not empty, otherwise it will use a combination of ID_MODEL and
-    ID_REVISION. The <quote>by-path</quote> mode will use the ID_PATH value.</para>
+    <para>观察包含一些 *_id 程序输出的行。
+    <quote>by-id</quote> 模式在 ID_SERIAL 存在且非空时会使用它,
+    否则就使用 ID_MODEL 和 ID_REVISION 的组合。
+    <quote>by-path</quote> 模式会使用 ID_PATH 的值。</para>
 
-    <para>If the default mode is not suitable for your situation, then the
-    following modification can be made to the
-    <filename>/etc/udev/rules.d/83-cdrom-symlinks.rules</filename> file,
-    as follows (where <replaceable>mode</replaceable> is one of
-    <quote>by-id</quote> or <quote>by-path</quote>):</para>
+    <para>如果默认模式不适合您的情况,可以像下面这样修改
+    <filename>/etc/udev/rules.d/83-cdrom-symlinks.rules</filename> 文件
+    (将 <replaceable>mode</replaceable> 替换成
+    <quote>by-id</quote> 或 <quote>by-path</quote> 中的一个):</para>
 
 <screen role="nodump"><userinput>sed -i -e 's/"write_cd_rules"/"write_cd_rules <replaceable>mode</replaceable>"/' \
     /etc/udev/rules.d/83-cdrom-symlinks.rules</userinput></screen>
 
-    <para>Note that it is not necessary to create the rules files or symlinks
-    at this time, because you have bind-mounted the host's
-    <filename class="directory">/dev</filename> directory into the LFS system,
-    and we assume the symlinks exist on the host. The rules and symlinks will
-    be created the first time you boot your LFS system.</para>
+    <para>注意现在并不需要创建规则文件和符号链接,因为已经绑定挂载了宿主的
+    <filename class="directory">/dev</filename> 目录,
+	我们假定宿主系统存在正确的符号链接。
+	只要在第一次引导 LFS 系统后创建规则和符号链接即可。</para>
 
-    <para>However, if you have multiple CD-ROM devices, then the symlinks
+    <!--para>However, if you have multiple CD-ROM devices, then the symlinks
     generated at that time may point to different devices than they point to on
     your host, because devices are not discovered in a predictable order. The
     assignments created when you first boot the LFS system will be stable, so
     this is only an issue if you need the symlinks on both systems to point to
     the same device. If you need that, then inspect (and possibly edit) the
     generated <filename>/etc/udev/rules.d/70-persistent-cd.rules</filename>
-    file after booting, to make sure the assigned symlinks match what you need.</para>
+    file after booting, to make sure the assigned symlinks match what you need.</para-->
+    <para>然而,如果您有多个 CD-ROM 设备,
+    则生成的符号链接可能指向不同于您的宿主系统的设备,
+	因为设备发现的顺序不可预测。在您第一次引导 LFS 系统后,
+	创建的设备分配将会是稳定的,因此这仅在您希望宿主系统和 LFS
+	中的符号链接指向同一设备时才会成为问题。
+	如果您需要这样,在引导后检查(如果需要的话修改)生成的
+	<filename>/etc/udev/rules.d/70-persistent-cd.rules</filename>
+	文件,保证分配的符号链接和您的需要一致。</para>
 
   </sect2>