| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910 | <?xml version="1.0" encoding="UTF-8"?><!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">  <!ENTITY site               SYSTEM "../appendices/rc.site.script">  %general-entities;]><sect1 id="ch-scripts-usage" revision="sysv">  <?dbhtml filename="usage.html"?>  <title>System V 启动脚本使用与配置</title>  <indexterm zone="ch-scripts-usage">    <primary sortas="a-Bootscripts">Bootscripts</primary>    <secondary>usage</secondary>  </indexterm>  <sect2>    <title>System V 启动脚本如何工作?</title>    <!--para>Linux uses a special booting facility named SysVinit that is based on a    concept of <emphasis>run-levels</emphasis>. It can be quite different from one    system to another, so it cannot be assumed that because things worked in one    particular Linux distribution, they should work the same in LFS too. LFS has its    own way of doing things, but it respects generally accepted standards.</para-->    <para>Linux 使用一种称为 SysVinit 的特殊引导架构,它基于        <emphasis>运行级别</emphasis> (run-level)的概念而构建。        不同系统的 SysVinit 可能会区别很大,        因此不能假设那些在某个 Linux 发行版上正常工作的方法也能在 LFS        正常工作。LFS 有自己的处事原则,但它也遵守被广泛接受的标准。    </para>      <!--para>SysVinit (which will be referred to as <quote>init</quote> from now on)    works using a run-levels scheme. There are seven (numbered 0 to 6) run-levels    (actually, there are more run-levels, but they are for special cases and are    generally not used. See <filename>init(8)</filename> for more details), and    each one of those corresponds to the actions the computer is supposed to    perform when it starts up. The default run-level is 3. Here are the    descriptions of the different run-levels as they are implemented:</para-->    <para>SysVinit(之后简称为 <quote>init</quote>)使用运行级别架构工作。        有七个(编号为 0 到 6)运行级别(实际上还有更多,        但它们用于一些特殊情况,一般并不使用。参阅        <filename>init(8)</filename> 了解更多细节),        每个都对应于计算机在启动时应该进行的一组操作。        默认运行级别是 3,下面是不同运行级别的描述:</para><literallayout>0: 停止系统运行1: 单用户模式2: 没有网络的多用户模式3: 有网络的多用户模式4: 保留用于自定义,如果没有自定义,和 3 相同5: 和 4 相同,一般用于 GUI 登录 (如 X 的 <command>xdm</command> 或 KDE 的 <command>kdm</command>)6: 重启计算机</literallayout>  </sect2>  <sect2 id="conf-sysvinit" role="configuration">  <title>配置 Sysvinit</title>  <indexterm zone="conf-sysvinit">    <primary sortas="a-Sysvinit">Sysvinit</primary>    <secondary>configuring</secondary>  </indexterm>  <indexterm zone="conf-sysvinit">    <primary sortas="e-/etc/inittab">/etc/inittab</primary>  </indexterm>  <!--para>During the kernel initialization, the first program that is run  is either specified on the command line or, by default  <command>init</command>.  This program reads the initialization file  <filename>/etc/inittab</filename>.  Create this file with:</para-->  <para>在内核初始化过程中,第一个运行的程序要么是内核命令行中指定的程序,      要么默认为 <command>init</command>。该程序读取初始化文件      <filename>/etc/inittab</filename>,执行以下命令创建该文件:</para><screen><userinput>cat > /etc/inittab << "EOF"<literal># Begin /etc/inittabid:3:initdefault:si::sysinit:/etc/rc.d/init.d/rc Sl0:0:wait:/etc/rc.d/init.d/rc 0l1:S1:wait:/etc/rc.d/init.d/rc 1l2:2:wait:/etc/rc.d/init.d/rc 2l3:3:wait:/etc/rc.d/init.d/rc 3l4:4:wait:/etc/rc.d/init.d/rc 4l5:5:wait:/etc/rc.d/init.d/rc 5l6:6:wait:/etc/rc.d/init.d/rc 6ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r nowsu:S016:once:/sbin/sulogin1:2345:respawn:/sbin/agetty --noclear tty1 96002:2345:respawn:/sbin/agetty tty2 96003:2345:respawn:/sbin/agetty tty3 96004:2345:respawn:/sbin/agetty tty4 96005:2345:respawn:/sbin/agetty tty5 96006:2345:respawn:/sbin/agetty tty6 9600# End /etc/inittab</literal>EOF</userinput></screen>  <!--para>An explanation of this initialization file is in the man page for  <emphasis>inittab</emphasis>.  For LFS, the key command that is run is  <command>rc</command>. The initialization file above will instruct  <command>rc</command> to run all the scripts starting with an S in the  <filename class="directory">/etc/rc.d/rcS.d</filename> directory  followed by all the scripts starting with an S in the <filename  class="directory">/etc/rc.d/rc?.d</filename> directory where the question  mark is specified by the initdefault value.</para-->  <para>在 <emphasis>inittab</emphasis> 的 man  页面中可以找到对该初始化文件的解释。对于 LFS,被执行的关键命令是  <command>rc</command>。上面的初始化文件会告诉 <command>rc</command>  先运行 <filename class="directory">/etc/rc.d/rcS.d</filename>  目录中所有名字以 S 开头的脚本,再运行  <filename class="directory">/etc/rc.d/rc?.d</filename>  中所有名字以 S 开头的脚本,这里问号表示 initdefault 值指定的默认运行级别。  </para>  <!--para>As a convenience, the <command>rc</command> script reads a library of  functions in <filename class="directory">/lib/lsb/init-functions</filename>.  This library also reads an optional configuration file,  <filename>/etc/sysconfig/rc.site</filename>.  Any of the system  configuration file parameters described in subsequent sections can be  alternatively placed in this file allowing consolidation of all system  parameters in this one file.</para-->  <para>为了方便起见,<command>rc</command> 脚本从  <filename class="directory">/lib/lsb/init-functions</filename>  中读取脚本函数库,这个库又会读取一个可选的配置文件  <filename>/etc/sysconfig/rc.site</filename>。  如果您希望将所有系统参数集中到一个文件中,  可以将以下各节中描述的所有系统配置文件参数都写入这一个文件。</para>  <!--para>As a debugging convenience, the functions script also logs all output  to <filename>/run/var/bootlog</filename>.  Since the <filename  class="directory">/run</filename> directory is a tmpfs, this file is not  persistent across boots, however it is appended to the more permanent file  <filename>/var/log/boot.log</filename> at the end of the boot process.</para-->  <para>为了方便调试,脚本函数库会将所有输出记录到  <filename>/run/var/bootlog</filename>。由于  <filename class="directory">/run</filename> 是 tmpfs,  这个文件在重新启动时不会被保留。然而,在引导过程结束时,  该文件的内容会被附加到更持久化的 <filename>/var/log/boot.log</filename>  文件末尾。</para>  <sect3 id="init-levels" >  <title>切换运行级别</title>  <para>通过运行 <command>init  <replaceable><runlevel></replaceable></command> 可以切换运行级别,  这里 <replaceable><runlevel></replaceable> 是要切换到的运行级别。  例如,如果要重新启动计算机,用户可以使用 <command>init 6</command> 命令,  它和 <command>reboot</command> 作用相同。同样,  <command>init 0</command> 和 <command>halt</command> 作用相同。</para>  <!--para>There are a number of directories under <filename  class="directory">/etc/rc.d</filename> that look like <filename  class="directory">rc?.d</filename> (where ? is the number of the run-level) and  <filename class="directory">rcsysinit.d</filename>, all containing a number of  symbolic links. Some begin with a <emphasis>K</emphasis>, the others begin with  an <emphasis>S</emphasis>, and all of them have two numbers following the  initial letter. The K means to stop (kill) a service and the S means to start a  service. The numbers determine the order in which the scripts are run, from 00  to 99—the lower the number the earlier it gets executed. When  <command>init</command> switches to another run-level, the appropriate services  are either started or stopped, depending on the runlevel chosen.</para-->  <para>在 <filename class="directory">/etc/rc.d</filename>  中有一些名字类似 <filename class="directory">rc?.d</filename>  的目录(这里 ? 是运行级别编号),以及一个目录  <filename class="directory">rcsysinit.d</filename>,  这些目录都包含一些符号链接。有的符号链接的名字以 <emphasis>K</emphasis>  开头,其他的则以 <emphasis>S</emphasis> 开头。它们的名字中,  第一个字符后都有两位数字。K 表示停止(杀死,kill)一个服务,  而 S 表示启动(start)一个服务。两位数字决定了运行这些脚本的顺序,  从 00 到 99 —— 数字较小的脚本更早执行。当 <command>init</command>  切换到另一个运行级别时,它会执行这些脚本,从而适当地启动或停止服务,  满足选择的运行级别要求。</para>  <para>符号链接实际指向的脚本位于 <filename  class="directory">/etc/rc.d/init.d</filename>,它们完成实际的工作。  K 链接和 S 链接指向  <filename class="directory">/etc/rc.d/init.d</filename>  中的相同脚本,这是因为脚本接受不同的参数,如  <parameter>start</parameter>、<parameter>stop</parameter>、  <parameter>restart</parameter>、<parameter>reload</parameter> 以及  <parameter>status</parameter>。当发现 K 链接时,脚本被传递  <parameter>stop</parameter> 参数。当发现 S 链接时,  对应的脚本被传递 <parameter>start</parameter> 参数。</para>  <para>以上解释有一个例外情况,当 <filename  class="directory">rc0.d</filename> 和 <filename  class="directory">rc6.d</filename> 目录中出现以 <emphasis>S</emphasis>  开头的链接时,它们不会启动任何服务。相反,它们被以参数  <parameter>stop</parameter> 调用,并停止服务。  这一行为背后的逻辑是,在重新启动系统或停止系统运行时,不需要启动任何服务,  只需要停止整个系统。</para>  <para>下面是脚本接受的不同参数及其解释:</para>  <variablelist>    <varlistentry>      <term><parameter>start</parameter></term>      <listitem>        <para>启动服务。</para>      </listitem>    </varlistentry>    <varlistentry>      <term><parameter>stop</parameter></term>      <listitem>        <para>停止服务。</para>      </listitem>    </varlistentry>    <varlistentry>      <term><parameter>restart</parameter></term>      <listitem>        <para>停止服务,再重新启动它。</para>      </listitem>    </varlistentry>    <varlistentry>      <term><parameter>reload</parameter></term>      <listitem>        <para>更新服务配置。        当服务的配置文件被修改后,如果不需要重新启动服务,        就使用该参数。</para>      </listitem>    </varlistentry>    <varlistentry>      <term><parameter>status</parameter></term>      <listitem>        <para>报告服务是否在运行中。如果正在运行,报告其 PID。</para>      </listitem>    </varlistentry>  </variablelist>  <para>您可以自由地修改引导过程的工作方式(毕竟这是您自己的 LFS 系统)。  我们给出的文件只是示例,用于展示它们可以完成的任务。</para>  </sect3>  </sect2>  <sect2>    <title>Udev 启动脚本</title>      <para><filename>/etc/rc.d/init.d/udev</filename> 初始化脚本启动      <command>udevd</command>,      触发内核已经创建的<quote>冷插拔</quote>设备,      等待其 udev 规则执行完毕。该脚本也会取消默认的 uevent 处理程序      <filename>/sbin/hotplug</filename>,      因为现在内核不再需要调用外部二进制程序,相反,      <command>udevd</command> 会监听一个 netlink 套接字,      以获取内核发出的 uevent 事件。</para>      <!--para>The <command>/etc/rc.d/init.d/udev_retry</command> initscript takes      care of re-triggering events for subsystems whose rules may rely on      filesystems that are not mounted until the <command>mountfs</command>      script is run (in particular, <filename class="directory">/usr</filename>      and <filename class="directory">/var</filename> may cause this).  This      script runs after the <command>mountfs</command> script, so those rules      (if re-triggered) should succeed the second time around.  It is      configured from the <filename>/etc/sysconfig/udev_retry</filename> file;      any words in this file other than comments are considered subsystem names      to trigger at retry time.  To find the subsystem of a device, use      <command>udevadm info - -attribute-walk <device></command> where      <device> is an absolute path in /dev or /sys such as /dev/sr0 or      /sys/class/rtc.</para-->      <para>某些子系统的 udev 规则依赖于一些直到 <command>mount_fs</command>      脚本被执行才会挂载的文件系统(如独立的      <filename class="directory">/usr</filename> 和      <filename class="directory">/var</filename> 文件系统就会导致这种现象)      初始化脚本 <command>/etc/rc.d/init.d/udev_retry</command>      负责重新触发这些子系统的事件。该脚本在 <command>mountfs</command>      后运行,因此这些规则(如果被重新触发)这一次应该能够成功执行。      配置文件 <filename>/etc/sysconfig/udev_retry</filename>      中包含的除注释外的所有单词都会被认为是一个需要触发的子系统。      为了找到某个设备的子系统,执行      <command>udevadm info --attribute-walk <device></command>,      这里 <device> 是一个 /dev 或 /sys 中的绝对路径,      例如 /dev/sr0 或 /sys/class/rtc。</para>      <note><title>译注</title>          <para>原文中这里有两小节与之前的              <xref linkend="ch-module-loading"/>、              <xref linkend="ch-hotplug-device"/> 重复,这里删去了。              上游将在 LFS 手册的下一个版本中删除它们。          </para>      </note>  </sect2>  <sect2 id="ch-scripts-clock">    <title>配置系统时钟</title>    <indexterm zone="ch-scripts-clock">      <primary sortas="d-scripts-setclock">setclock</primary>    <secondary>configuring</secondary></indexterm>    <!--para>The <command>setclock</command> script reads the time from the hardware    clock, also known as the BIOS or the Complementary Metal Oxide Semiconductor    (CMOS) clock. If the hardware clock is set to UTC, this script will convert the    hardware clock's time to the local time using the    <filename>/etc/localtime</filename> file (which tells the    <command>hwclock</command> program which timezone the user is in). There is no    way to detect whether or not the hardware clock is set to UTC, so this    needs to be configured manually.</para-->    <para><command>setclock</command> 脚本从硬件时钟读取时间,    硬件时钟又被称为 BIOS 时钟或互补金属氧化物半导体(CMOS)时钟。    如果硬件时钟被设为 UTC 时间,该脚本会根据    <filename>/etc/localtime</filename> 文件(它告知    <command>hwclock</command> 程序用户处于哪个时区),    将硬件时钟的时间转换成本地时间。不存在确定硬件时钟是否设为 UTC 的方法,    因此这必须手动设置。</para>    <!--para>The <command>setclock</command> is run via    <application>udev</application> when the kernel detects the hardware    capability upon boot.  It can also be run manually with the stop parameter to    store the system time to the CMOS clock.</para-->    <para>在引导后,内核检测硬件功能时,<command>setclock</command> 脚本被    <application>udev</application> 执行。可以用 stop 参数手动调用它,    以将系统时间写入 CMOS 时钟。</para>    <!--para>If you cannot remember whether or not the hardware clock is set to UTC,    find out by running the <userinput>hwclock localtime show</userinput>    command. This will display what the current time is according to the hardware    clock. If this time matches whatever your watch says, then the hardware clock is    set to local time. If the output from <command>hwclock</command> is not local    time, chances are it is set to UTC time. Verify this by adding or subtracting    the proper amount of hours for the timezone to the time shown by    <command>hwclock</command>. For example, if you are currently in the MST    timezone, which is also known as GMT -0700, add seven hours to the local    time.</para-->    <para>如果您不确定您的硬件时钟是否设置为 UTC ,运行    <userinput>hwclock --localtime --show</userinput> 命令,    它会显示硬件时钟给出的当前时间。如果这个时间和您的手表显示的一致,    则说明硬件时钟被设定为本地时间。相反,如果 <command>hwclock</command>    输出的时间不是本地时间,则硬件时钟很可能被设定为 UTC 时间。    根据您的时区,在 <command>hwclock</command>    显示的时间上加减对应的小时数,进行进一步的验证。    例如,如果您现在处于莫斯科时区,即 GMT -0700 ,在本地时间上加    7 小时,再进行比较。</para>    <!--para>Change the value of the <envar>UTC</envar> variable below    to a value of <parameter>0</parameter> (zero) if the hardware clock    is <emphasis>not</emphasis> set to UTC time.</para-->    <para>如果硬件时钟<emphasis>没有</emphasis>设为 UTC 时间,    在下面的配置文件中,应该将 <envar>UTC</envar> 变量的值设为    <parameter>0</parameter>。</para>    <note><title>译注</title>    <para>Windows 会将硬件时钟设定为本地时间,因此如果您要同时安装    Windows 和 Linux,就要将 Linux (包括 LFS 和其他发行版)    配置为使用本地时间,除非能够忍受 Windows 和 Linux 显示的不同时间   (必有一个是错误的)。    </para></note>    <!--para>Create a new file <filename>/etc/sysconfig/clock</filename> by running    the following:</para-->    <para>执行以下命令,创建一个新的    <filename>/etc/sysconfig/clock</filename> 文件:</para><screen><userinput>cat > /etc/sysconfig/clock << "EOF"<literal># Begin /etc/sysconfig/clockUTC=1# 将该变量设置为您希望传递给 hwclock 命令的选项,# 例如 Alpha 机器上的硬件时钟类型。CLOCKPARAMS=# End /etc/sysconfig/clock</literal>EOF</userinput></screen>    <!--para>A good hint explaining how to deal with time on LFS is available    at <ulink url="&hints-root;time.txt"/>. It explains issues such as    time zones, UTC, and the <envar>TZ</envar> environment variable.</para-->    <para>访问 <ulink url="&hints-root;time.txt"/> ,    可以找到一个关于如何在 LFS 系统中处理时间问题的好的提示。    它解释了时区、UTC 和 <envar>TZ</envar> 环境变量等问题。</para>    <note><para>CLOCKPARAMS 和 UTC 参数也可在    <filename>/etc/sysconfig/rc.site</filename> 文件中设定。</para></note>  </sect2>  <sect2 id="ch-scripts-console">  <?dbhtml filename="console.html"?>  <title>配置 Linux 控制台</title>  <indexterm zone="ch-scripts-console">    <primary sortas="d-console">console</primary>    <secondary>configuring</secondary>  </indexterm>  <!--para>This section discusses how to configure the <command>console</command>  bootscript that sets up the keyboard map, console font and console kernel log  level. If non-ASCII characters (e.g., the copyright sign, the British pound  sign and Euro symbol) will not be used and the keyboard is a U.S. one, much  of this section can be skipped. Without the configuration file, (or  equivalent settings in <filename>rc.site</filename>), the  <command>console</command> bootscript will do nothing.</para-->  <para>本节讨论如何配置 <command>console</command> 启动脚本,  使之正确设定键盘映射、控制台字体和控制台内核日志级别。  如果不使用非 ASCII 字符(如版权符号、英镑或欧元符号),  且键盘是美式的,则可以跳过本节。如果不创建本节的配置文件  (且 <filename>rc.site</filename> 中也没有对应的设置),  则 <command>console</command> 脚本什么也不做。</para>  <!--para>The <command>console</command> script reads the  <filename>/etc/sysconfig/console</filename> file for configuration  information.  Decide which keymap and screen font will be used. Various  language-specific HOWTOs can also help with this, see <ulink  url="http://www.tldp.org/HOWTO/HOWTO-INDEX/other-lang.html"/>. If still in  doubt, look in the <filename class="directory">/usr/share/keymaps</filename>  and <filename class="directory">/usr/share/consolefonts</filename> directories  for valid keymaps and screen fonts. Read <filename>loadkeys(1)</filename> and  <filename>setfont(8)</filename> manual pages to determine the correct  arguments for these programs.</para-->  <para><command>console</command> 脚本读取  <filename>/etc/sysconfig/console</filename> 文件中的配置信息,  据此确定使用哪种键映射和控制台字体。一些与特定语言相关的  HOWTO 文档可以帮助您进行配置,参阅  <ulink url="http://www.tldp.org/HOWTO/HOWTO-INDEX/other-lang.html"/>。  如果仍然存在疑问,在  <filename class="directory">/usr/share/keymaps</filename> 和  <filename class="directory">/usr/share/consolefonts</filename>  目录中寻找可用的键映射和屏幕字体,并阅读 <filename>loadkeys(1)</filename>  和 <filename>setfont(8)</filename> man 手册页面,  以确认应该传递给这两个程序的正确参数。</para>  <!--para>The <filename>/etc/sysconfig/console</filename> file should contain lines  of the form: VARIABLE="value". The following variables are recognized:</para-->  <para><filename>/etc/sysconfig/console</filename>  文件应当包含若干行,它们的格式为:变量名="值"。下列变量名会被识别:</para>  <variablelist>    <varlistentry>      <term>LOGLEVEL</term>      <listitem>        <!--para>This variable specifies the log level for kernel messages sent        to the console as set by <command>dmesg</command>. Valid levels are        from "1" (no messages) to "8". The default level is "7".</para-->        <para>该变量指定被发送到终端的内核消息日志等级,        正如使用 <command>dmesg -n</command> 设置的那样。        有效的等级是 "1"(不输出消息) 到 "8" 之间的某个数,        默认值是 "7"。</para>      </listitem>    </varlistentry>    <varlistentry>      <term>KEYMAP</term>      <listitem>        <!--para>This variable specifies the arguments for the        <command>loadkeys</command> program, typically, the name of keymap        to load, e.g., <quote>it</quote>. If this variable is not set, the        bootscript will not run the <command>loadkeys</command> program,        and the default kernel keymap will be used.  Note that a few keymaps        have multiple versions with the same name (cz and its variants in        qwerty/ and qwertz/, es in olpc/ and qwerty/, and trf in fgGIod/ and        qwerty/). In these cases the parent directory should also be specified        (e.g. qwerty/es) to ensure the proper keymap is loaded.        </para-->        <para>该变量指定传递给 <command>loadkeys</command> 程序的参数,        通常为希望加载的键映射表名,例如 <quote>it</quote>。        如果没有设置这个变量,启动脚本不会运行 <command>loadkeys</command>,        并使用默认键映射。注意某些键映射表有名字相同的不同版本        (如 cz 及其变式在 qwerty/ 和 qwertz/ 中同时存在,        es 在 olpc/ 和 qwerty/ 中同时存在,trf 在 fgGIod/ 和 qwerty/        中同时存在),此时就要把包含键映射表文件的目录名也写在该变量中        (如 qwerty/es),才能保证加载正确的键映射。</para>      </listitem>    </varlistentry>    <varlistentry>      <term>KEYMAP_CORRECTIONS</term>      <listitem>        <!--para>This (rarely used) variable        specifies the arguments for the second call to the        <command>loadkeys</command> program. This is useful if the stock keymap        is not completely satisfactory and a small adjustment has to be made. E.g.,        to include the Euro sign into a keymap that normally doesn't have it,        set this variable to <quote>euro2</quote>.</para-->        <para>这个(很少使用的)变量指定第二次调用        <command>loadkeys</command> 程序时的参数。        如果您希望对现成的,但不完全符合要求的键映射表进行微调,        这个变量很有用。例如,为了在不包含欧元符号的键映射中附加它,        可以设定该变量为 <quote>euro2</quote>。</para>      </listitem>    </varlistentry>    <varlistentry>      <term>FONT</term>      <listitem>        <!--para>This variable specifies the arguments for the        <command>setfont</command> program. Typically, this includes the font        name, <quote>-m</quote>, and the name of the application character        map to load. E.g., in order to load the <quote>lat1-16</quote> font        together with the <quote>8859-1</quote> application character map        (as it is appropriate in the USA),-->        <!-- because of the copyright sign -->        <!-- set this variable to <quote>lat1-16 -m 8859-1</quote>.        In UTF-8 mode, the kernel uses the application character map for        conversion of composed 8-bit key codes in the keymap to UTF-8, and thus        the argument of the "-m" parameter should be set to the encoding of the        composed key codes in the keymap.</para-->        <para>该变量指定传递给 <command>setfont</command> 程序的参数。        它一般包含字体名、<quote>-m</quote> 以及需要加载的应用字符映射名,        例如,如果要加载 <quote>lat1-16</quote> 字体,以及        <quote>8859-1</quote> 应用字符映射(它适用于美国),        就将该变量设置为 <quote>lat1-16 -m 8859-1</quote>。        在 UTF-8 模式下,内核根据应用字符映射,将键映射中的        8 位键码组合转换成 UTF-8,因此 <quote>-m</quote>        参数的值应该被设为键映射中键码组合的编码。</para>      </listitem>    </varlistentry>    <varlistentry>      <term>UNICODE</term>      <listitem>        <!--para>Set this variable to <quote>1</quote>, <quote>yes</quote> or        <quote>true</quote> in order to put the        console into UTF-8 mode. This is useful in UTF-8 based locales and        harmful otherwise.</para-->        <para>将该变量设置为 <quote>1</quote>、<quote>yes</quote> 或        <quote>true</quote>,可以将终端设置为 UTF-8 模式。        这对于基于 UTF-8 的 locale 来说很有用,但对于其他 locale 有害。        </para>      </listitem>    </varlistentry>    <varlistentry>      <term>LEGACY_CHARSET</term>      <listitem>        <!--para>For many keyboard layouts, there is no stock Unicode keymap in        the Kbd package. The <command>console</command> bootscript will        convert an available keymap to UTF-8 on the fly if this variable is        set to the encoding of the available non-UTF-8 keymap.</para-->        <para>对于许多键盘布局,Kbd 软件包不包含现成的 Unicode 键映射。        如果将该变量设置为可用的非 UTF-8 键映射的编码,则        <command>console</command>        启动脚本会将可用的键映射即时转换成 UTF-8。</para>      </listitem>    </varlistentry>  </variablelist>  <para>一些例子:</para>  <itemizedlist>    <listitem>      <!--para>For a non-Unicode setup, only the KEYMAP and FONT variables are      generally needed. E.g., for a Polish setup, one would use:</para-->      <para>对于非 Unicode 设置,一般只需要 KEYMAP 和 FONT 变量。      例如,下面是一个波兰语设置:</para><screen role="nodump"><userinput>cat > /etc/sysconfig/console << "EOF"<literal># Begin /etc/sysconfig/consoleKEYMAP="pl2"FONT="lat2a-16 -m 8859-2"# End /etc/sysconfig/console</literal>EOF</userinput></screen>    </listitem>    <listitem>      <!--para>As mentioned above, it is sometimes necessary to adjust a      stock keymap slightly. The following example adds the Euro symbol to the      German keymap:</para-->      <para>正如前文所述,有时需要微调一个现有的键映射,      下面的例子为德语键映射增加欧元符号:</para><screen role="nodump"><userinput>cat > /etc/sysconfig/console << "EOF"<literal># Begin /etc/sysconfig/consoleKEYMAP="de-latin1"KEYMAP_CORRECTIONS="euro2"FONT="lat0-16 -m 8859-15"# End /etc/sysconfig/console</literal>EOF</userinput></screen>    </listitem>    <listitem>      <!--para>The following is a Unicode-enabled example for Bulgarian, where a      stock UTF-8 keymap exists:</para-->      <para>下面是使用 Unicode 的白罗斯语配置,对于该语言,      可以使用已有的 UTF-8 键映射:</para><screen role="nodump"><userinput>cat > /etc/sysconfig/console << "EOF"<literal># Begin /etc/sysconfig/consoleUNICODE="1"KEYMAP="bg_bds-utf8"FONT="LatArCyrHeb-16"# End /etc/sysconfig/console</literal>EOF</userinput></screen>    </listitem>    <listitem>      <!--para>Due to the use of a 512-glyph LatArCyrHeb-16 font in the previous      example, bright colors are no longer available on the Linux console unless      a framebuffer is used. If one wants to have bright colors without      framebuffer and can live without characters not belonging to his language,      it is still possible to use a language-specific 256-glyph font, as      illustrated below:</para-->      <para>由于上面的例子使用了 512 个字形的 LatArCyrHeb-16 字体,      在 Linux 终端中不能继续使用明亮的颜色,除非使用了帧缓冲。      如果希望在没有帧缓冲的情况下使用明亮的颜色,      且不需要那些不属于自己母语的字符,可以使用特定语言的 256 字形字体,      配置文件如下:</para><screen role="nodump"><userinput>cat > /etc/sysconfig/console << "EOF"<literal># Begin /etc/sysconfig/consoleUNICODE="1"KEYMAP="bg_bds-utf8"FONT="cyr-sun16"# End /etc/sysconfig/console</literal>EOF</userinput></screen>    </listitem>    <listitem>      <!--para>The following example illustrates keymap autoconversion from      ISO-8859-15 to UTF-8 and enabling dead keys in Unicode mode:</para-->      <para>下面的例子展示了从 ISO-8859-15 到 UTF-8 的键映射自动转换,      同时在 Unicode 模式下启用了死键:</para><screen role="nodump"><userinput>cat > /etc/sysconfig/console << "EOF"<literal># Begin /etc/sysconfig/consoleUNICODE="1"KEYMAP="de-latin1"KEYMAP_CORRECTIONS="euro2"LEGACY_CHARSET="iso-8859-15"FONT="LatArCyrHeb-16 -m 8859-15"# End /etc/sysconfig/console</literal>EOF</userinput></screen>    </listitem>    <listitem>      <!--para>Some keymaps have dead keys (i.e., keys that don't produce a      character by themselves, but put an accent on the character produced      by the next key) or define composition rules (such as: <quote>press      Ctrl+. A E to get Æ</quote> in the default keymap).      Linux-&linux-version; interprets dead keys and composition rules in the      keymap correctly only when the source characters to be composed together      are not multibyte. This deficiency doesn't affect keymaps for European      languages, because there accents are added to unaccented ASCII      characters, or two ASCII characters are composed together. However, in      UTF-8 mode it is a problem, e.g., for the Greek language, where one      sometimes needs to put an accent on the letter <quote>alpha</quote>.      The solution is either to avoid the use of UTF-8, or to install the      X window system that doesn't have this limitation in its input      handling.</para-->      <para>某些键映射有死键(即,这些键本身不产生字符,      而是在下一次按键产生的字符上附加音调)或定义了组合规则      (例如在默认键映射中,<quote>按下 Ctrl+. A E 得到 Æ</quote>)。      Linux-&linux-version; 只有在被组合的不是多字节字符的情况下,      才能正常解析死键和组合规则。这个缺陷不影响欧洲语言的键映射,      因为在欧洲语言中要么是一个音调被附加到不带音调的 ASCII 字符上,      要么是两个 ASCII 字符被组合在一起。然而,在 UTF-8 模式中,      以希腊语为例,当某人要在 <quote>alpha</quote> 字符上附加一个音调时,      就会出现问题。解决方法是要么不使用 UTF-8,要么安装 X 窗口系统,      它处理输入时没有这个限制。</para>    </listitem>    <listitem>      <!--para>For Chinese, Japanese, Korean and some other languages, the Linux      console cannot be configured to display the needed characters. Users      who need such languages should install the X Window System, fonts that      cover the necessary character ranges, and the proper input method (e.g.,      SCIM, it supports a wide variety of languages).</para-->      <para>对于中文、日文、韩文以及其他一些语言文字,      不可能配置 Linux 终端,使其正常显示需要的字符。      这些语言的用户需要安装 X 窗口系统、能够覆盖需要的字符的字体,      以及合适的输入法(如 SCIM 支持许多语言的输入)。</para>    </listitem>  </itemizedlist>  <!-- Added because folks keep posting their console file with X questions  to blfs-support list -->  <note>    <!--para>The <filename>/etc/sysconfig/console</filename> file only controls    the Linux text console localization. It has nothing to do with setting    the proper keyboard layout and terminal fonts in the X Window System, with    ssh sessions or with a serial console. In such situations, limitations    mentioned in the last two list items above do not apply.</para-->    <para><filename>/etc/sysconfig/console</filename> 文件只控制 Linux    字符终端的本地化,它和 X 窗口系统、ssh 连接、    串口等其他终端中的键盘布局设置和终端字体毫无关系。在这些情况下,    不存在上面描述的两项限制。</para>  </note>  </sect2>  <sect2 id="ch-scripts-createfiles">    <title>在引导时创建文件</title>      <indexterm zone="ch-scripts-createfiles">      <primary sortas="d-createfiles">File creation at boot</primary>      <secondary>configuring</secondary>    </indexterm>      <!--para>At times, it is desired to create files at boot time.  For instance,    the <filename class="directory">/tmp/.ICE-unix</filename> directory    may be desired.  This can be done by creating an entry in the    <filename>/etc/sysconfig/createfiles</filename> configuration script.    The format of this file is embedded in the comments of the default     configuration file.</para-->    <para>有时,我们希望在引导时创建一些文件,例如    <filename class="directory">/tmp/ICE-unix</filename> 目录。    为此,可以在 <filename>/etc/sysconfig/createfiles</filename>    配置脚本中创建一项,该文件的格式包含在默认配置文件的注释中。</para>  </sect2>  <sect2 id="ch-scripts-sysklogd">    <title>配置 sysklogd 脚本</title>      <indexterm zone="ch-scripts-sysklogd">      <primary sortas="d-sysklogd">sysklogd</primary>      <secondary>configuring</secondary>    </indexterm>      <!--para>The <filename>sysklogd</filename> script invokes the    <command>syslogd</command> program as a part of System V initialization.  The    <parameter>-m 0</parameter> option turns off the periodic timestamp mark that    <command>syslogd</command> writes to the log files every 20 minutes by    default.  If you want to turn on this periodic timestamp mark, edit    <filename>/etc/sysconfig/rc.site</filename> and define the variable    SYSKLOGD_PARMS to the desired value.  For instance, to remove all parameters,    set the variable to a null value:</para-->    <para><filename>sysklogd</filename> 脚本启动    <command>syslogd</command> 程序,它是 System V 初始化的一部分。    <parameter>-m 0</parameter> 选项关闭 <command>sysklogd</command>    每 20 分钟写入日志文件的周期性时间戳,如果您希望启用该时间戳,    编辑 <filename>/etc/sysconfig/rc.site</filename>,    将 SYSKLOGD_PARMS 定义为您希望的值。例如,如果要删除所有参数,    将该变量设定为空:</para><screen role="nodump">SYSKLOGD_PARMS=</screen>    <para>参阅 <userinput>man syslogd</userinput> 了解更多可用选项。</para>  </sect2>  <sect2 id="ch-scripts-site">    <title>rc.site 文件</title>      <indexterm zone="ch-scripts-site">      <primary sortas="a-rc.site">rc.site</primary>    </indexterm>      <!--para>The optional <filename>/etc/sysconfig/rc.site</filename> file contains    settings that are automatically set for each SystemV boot script.  It can    alternatively set the values specified in the <filename>hostname</filename>,    <filename>console</filename>, and <filename>clock</filename> files in the    <filename class='directory'>/etc/sysconfig/</filename> directory.  If the    associated variables are present in both these separate files and    <filename>rc.site</filename>, the values in the script specific files have    precedence. </para-->    <para>可选的 <filename>/etc/sysconfig/rc.site</filename>    文件包含为每个 System V 启动脚本自动设定的设置。    <filename class="directory">/etc/sysconfig/</filename>    目录中 <filename>hostname</filename>、<filename>console</filename>    以及 <filename>clock</filename> 文件的变量值也可以在    <filename>rc.site</filename> 中设置。    如果某个变量存在于这三个文件当中,它们会覆盖    <filename>rc.site</filename> 中的设定。</para>      <!--para><filename>rc.site</filename> also contains parameters that can    customize other aspects of the boot process.  Setting the IPROMPT variable    will enable selective running of bootscripts.  Other options are described    in the file comments.  The default version of the file is as follows:</para-->    <para><filename>rc.site</filename>    还包含用于自定义引导过程其他属性的变量。    设定 IPROMPT 变量会启用引导脚本的选择性执行,    其他选项在文件注释中有描述。该文件的默认版本如下:</para>      <!-- Use role to fix a pdf generation problem -->    <screen role="auto">&site;</screen>      <sect3>      <title>自定义开关机脚本</title>        <!--para>The LFS boot scripts boot and shut down a system in a fairly      efficient manner, but there are a few tweaks that you can make in the      rc.site file to improve speed even more and to adjust messages according      to your preferences. To do this, adjust the settings in      the <filename>/etc/sysconfig/rc.site</filename> file above.</para-->      <para>LFS 启动脚本能够较为高效地引导和关闭系统,      但您仍然可以进行一些调整,进一步提高速度,      并根据您的喜好修改屏幕显示的消息。为此,需要修改上面给出的      <filename>/etc/sysconfig/rc.site</filename> 文件。</para>      <itemizedlist>        <!--listitem><para>During the boot script <filename>udev</filename>, there is      a call to <command>udev settle</command> that requires some time to      complete. This time may or may not be required depending on devices present      in the system.  If you only have simple partitions and a single ethernet      card, the boot process will probably not need to wait for this command.  To      skip it, set the variable OMIT_UDEV_SETTLE=y.</para></listitem-->      <listitem><para>在启动脚本 <filename>udev</filename>      的运行过程中,它执行 <command>udev settle</command> 命令,      该命令需要较长时间才能完成。然而这个执行时间或许不是必要的,      如果您只有简单分区,且仅有一块网卡,      那么引导过程可能不需要等待该命令完成。设定变量      OMIT_UDEV_SETTLE=y,可以跳过该命令。</para></listitem>      <!--listitem><para>The boot script <filename>udev_retry</filename> also runs      <command>udev settle</command> by default.  This command is only needed by      default if the <filename class='directory'>/var</filename> directory is      separately mounted.  This is because the clock needs the file      <filename>/var/lib/hwclock/adjtime</filename>.  Other customizations may      also need to wait for udev to complete, but in many installations it is not      needed.  Skip the command by setting the variable OMIT_UDEV_RETRY_SETTLE=y.      </para></listitem-->      <listitem><para>启动脚本 <filename>udev_retry</filename>      默认情况下也会执行 <command>udev settle</command>。      一般来说,该命令只有 <filename class="directory">/var</filename>      目录是一个单独的挂载点时才必要,这是因为系统时钟需要文件      <filename>/var/lib/hwclock/adjtime</filename>。      其他的定制也可能导致该脚本需要等待 udev 完成,      但在绝大多数 LFS 系统中没有这个必要。      设定变量 OMIT_UDEV_RETRY_SETTLE=y 跳过这一命令。</para></listitem>      <!--listitem><para>By default, the file system checks are silent.  This can      appear to be a delay during the bootup process.  To turn on the      <command>fsck</command> output, set the variable VERBOSE_FSCK=y.      </para></listitem-->      <listitem><para>默认情况下,文件系统检查是安静(没有输出)的。      因此,在引导过程中,检查过程可能看上去是一个很长的时延。      设置变量 VERBOSE_FSCK=y 可以打开 <command>fsck</command> 的输出。      </para></listitem>        <!--listitem><para>When rebooting, you may want to skip the filesystem check,      <command>fsck</command>, completely.  To do this, either create the file      <filename>/fastboot</filename> or reboot the system with the command      <command>/sbin/shutdown -f -r now</command>.  On the other hand, you can      force all file systems to be checked by creating      <filename>/forcefsck</filename> or running <command>shutdown</command> with      the <parameter>-F</parameter> parameter instead of <parameter>-f</parameter>.  </para-->      <listitem><para>在重启系统时,您可能希望完全跳过文件系统检查命令      <command>fsck</command>。为此,可以创建文件      <filename>/fastboot</filename>,或使用命令      <command>/sbin/shutdown -f -r now</command> 重启系统。      另一方面,您可以创建 <filename>/forcefsck</filename> 文件,      或使用 <parameter>-F</parameter> 参数(而不是      <parameter>-f</parameter>)运行 <command>shutdown</command>,      在重启系统时强制检查所有文件系统。</para>        <!--para>Setting the variable FASTBOOT=y will disable <command>fsck</command>      during the boot process until it is removed.  This is not recommended      on a permanent basis.</para></listitem-->      <para>设定变量 FASTBOOT=y 会完全禁止引导过程中 <command>fsck</command>      的执行,直到该变量被删除。不建议永久使用该变量。</para></listitem>      <!--listitem><para>Normally, all files in the <filename      class='directory'>/tmp</filename> directory are deleted at boot time.      Depending on the number of files or directories present, this can cause a      noticeable delay in the boot process.  To skip removing these files set the      variable SKIPTMPCLEAN=y.</para></listitem-->      <listitem><para>正常情况下,      <filename class="directory">/tmp</filename>      中的所有文件在引导时都被删除。如果其中的文件和目录较多,      可能在引导过程中造成可观的延迟。设定变量 SKIPTMPCLEAN=y      可以跳过删除这些文件的过程。</para></listitem>      <!--listitem><para>During shutdown, the <command>init</command> program sends      a TERM signal to each program it has started (e.g. agetty), waits for a set      time (default 3 seconds), and sends each process a KILL signal and waits      again.  This process is repeated in the <command>sendsignals</command>      script for any processes that are not shut down by their own scripts.  The      delay for <command>init</command> can be set by passing a parameter.  For      example to remove the delay in <command>init</command>, pass the -t0      parameter when shutting down or rebooting (e.g.  <command>/sbin/shutdown      -t0 -r now</command>).  The delay for the  <command>sendsignals</command>      script can be skipped by setting the parameter      KILLDELAY=0.</para></listitem-->      <listitem><para>在系统关闭的过程中,<command>init</command>      向它启动的所有程序(如 getty)发送一个 TERM 信号,等待一段时间      (默认 3 秒),再向每个进程发送 KILL 信号,之后再次等待。      在 <command>sendsignals</command> 脚本中,      以上过程会对那些没有被自己的引导脚本关闭的进程再次执行。      <command>init</command> 的时延可以通过传递参数设定,      为了完全取消时延,可以在关闭或重启系统时使用 -t0 参数      (如 <command>shutdown -t0 -r now</command>)。      <command>sendsignals</command> 脚本的时延可以通过设定参数      KILLDELAY=0 跳过。</para></listitem>        </itemizedlist>      </sect3>  </sect2></sect1>
 |