introduction.xml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  4. <!ENTITY % general-entities SYSTEM "../general.ent">
  5. %general-entities;
  6. ]>
  7. <sect1 id="ch-scripts-introduction" revision="sysv">
  8. <?dbhtml filename="introduction.html"?>
  9. <title>概述</title>
  10. <!--para>Booting a Linux system involves several tasks. The process must
  11. mount both virtual and real file systems, initialize devices, activate swap,
  12. check file systems for integrity, mount any swap partitions or files, set
  13. the system clock, bring up networking, start any daemons required by the
  14. system, and accomplish any other custom tasks needed by the user. This
  15. process must be organized to ensure the tasks are performed in the correct
  16. order but, at the same time, be executed as fast as possible.</para-->
  17. <para>引导 Linux 系统需要完成若干任务。
  18. 引导过程必须挂载虚拟和真实文件系统、初始化设备、启用交换、
  19. 检查文件系统完整性、挂载所有交换分区或文件、设定系统时钟、
  20. 启用网络、启动系统需要的守护进程,并完成用户自定义的其他工作。
  21. 引导过程必须被组织好,以保证这些任务以正确顺序进行,
  22. 并以尽量快的速度完成。</para>
  23. <!-- <para>In the packages that were installed in Chapter&nbsp;6, there were two
  24. different boot systems installed. LFS provides the ability to easily
  25. select which system the user wants to use and to compare and contrast the
  26. two systems by actually running each system on the local computer. The
  27. advantages and disadvantages of these systems is presented below.</para>-->
  28. <sect2 id='sysv-desc'>
  29. <title>System V</title>
  30. <!--para>System V is the classic boot process that has been used in Unix and
  31. Unix-like systems such as Linux since about 1983. It consists of a small
  32. program, <command>init</command>, that sets up basic programs such as
  33. <command>login</command> (via getty) and runs a script. This script,
  34. usually named <command>rc</command>, controls the execution of a set of
  35. additional scripts that perform the tasks required to initialize the
  36. system.</para>
  37. <para>The <command>init</command> program is controlled by the
  38. <filename>/etc/inittab</filename> file and is organized into run levels that
  39. can be run by the user:</para-->
  40. <para>System V 是自 1983 年以来就在 Unix 和 Linux 等类 Unix
  41. 系统中被广泛应用的经典引导过程。它包含一个小程序
  42. <command>init</command>,该程序设定 <command>login</command>
  43. (通过 getty)并运行一个脚本。该脚本一般被命名为
  44. <command>rc</command>,控制一组附加脚本的运行,
  45. 这些附加脚本完成初始化系统需要的各项工作。</para>
  46. <para><command>init</command> 程序受到 <filename>/etc/inittab</filename>
  47. 文件的控制,被组织为用户可以选择的系统运行级别:</para>
  48. <literallayout>
  49. 0 &mdash; 停止运行
  50. 1 &mdash; 单用户模式
  51. 2 &mdash; 多用户模式,没有网络
  52. 3 &mdash; 完整的多用户模式
  53. 4 &mdash; 用户自定义模式
  54. 5 &mdash; 拥有显示管理器的完整多用户模式
  55. 6 &mdash; 重启系统
  56. </literallayout>
  57. <para>通常的默认运行级别是 3 或 5。</para>
  58. <bridgehead renderas="sect3">优点</bridgehead>
  59. <itemizedlist>
  60. <listitem>
  61. <para>完备的,已经被详细理解的系统。</para>
  62. </listitem>
  63. <listitem>
  64. <para>容易定制。</para>
  65. </listitem>
  66. </itemizedlist>
  67. <bridgehead renderas="sect3">缺点</bridgehead>
  68. <itemizedlist>
  69. <listitem>
  70. <!--para>Slower to boot. A medium speed base LFS system
  71. takes 8-12 seconds where the boot time is measured from the
  72. first kernel message to the login prompt. Network
  73. connectivity is typically established about 2 seconds
  74. after the login prompt.</para-->
  75. <para>引导速度较慢。一个中等速度的基本 LFS
  76. 系统从第一个内核消息开始,到出现登录提示符为止,
  77. 需要 8-12 秒的引导时间,之后还需要约 2 秒启动网络连接。
  78. </para>
  79. </listitem>
  80. <listitem>
  81. <!--para>Serial processing of boot tasks. This is related to the previous
  82. point. A delay in any process such as a file system check, will
  83. delay the entire boot process.</para-->
  84. <para>串行执行引导任务,这与前一项缺点相关。
  85. 引导过程中的延迟(如文件系统检查)会延迟整个引导过程。</para>
  86. </listitem>
  87. <listitem>
  88. <para>不支持控制组(cgroups)、每用户公平共享调度等高级特性。
  89. </para>
  90. </listitem>
  91. <listitem>
  92. <para>添加脚本时,需要手动决定它在引导过程中的次序。</para>
  93. </listitem>
  94. </itemizedlist>
  95. </sect2>
  96. <!--
  97. <sect2 id='sysd-desc'>
  98. <title>Systemd</title>
  99. <para>Systemd is a group of interconnected programs that handles system and
  100. individual process requests. It provides a dependency system between
  101. various entities called "units". It automatically addresses dependencies
  102. between units and can execute several startup tasks in parallel. It
  103. provides login, inetd, logging, time, and networking services. </para>
  104. <bridgehead renderas="sect3">Advantages</bridgehead>
  105. <itemizedlist>
  106. <listitem>
  107. <para>Used on many established distributions by default.</para>
  108. </listitem>
  109. <listitem>
  110. <para>There is extensive documentation.
  111. See <ulink url="http://www.freedesktop.org/wiki/Software/systemd/"/>.</para>
  112. </listitem>
  113. <listitem>
  114. <para>Parallel execution of boot processes. A medium speed
  115. base LFS system takes 6-10 seconds from kernel start to a
  116. login prompt. Network connectivity is typically established
  117. about 2 seconds after the login prompt. More complex startup
  118. procedures may show a greater speedup when compared to System V.</para>
  119. </listitem>
  120. <listitem>
  121. <para>Implements advanced features such as control groups to
  122. manage related processes.</para>
  123. </listitem>
  124. <listitem>
  125. <para>Maintains backward compatibility with System V programs
  126. and scripts.</para>
  127. </listitem>
  128. </itemizedlist>
  129. <bridgehead renderas="sect3">Disadvantages</bridgehead>
  130. <itemizedlist>
  131. <listitem>
  132. <para>There is a substantial learning curve.</para>
  133. </listitem>
  134. <listitem>
  135. <para>Some advanced features such as dbus or cgroups cannot be
  136. disabled if they are not otherwise needed.</para>
  137. </listitem>
  138. <listitem>
  139. <para>Although implemented as several executable programs
  140. the user cannot choose to implement only the portions desired.</para>
  141. </listitem>
  142. <listitem>
  143. <para>Due to the nature of using compiled programs, systemd is
  144. more difficult to debug.</para>
  145. </listitem>
  146. <listitem>
  147. <para>Logging is done in a binary format. Extra tools must
  148. be used to process logs or additional processes must be implemented
  149. to duplicate traditional logging programs.</para>
  150. </listitem>
  151. </itemizedlist>
  152. </sect2>
  153. -->
  154. <!--
  155. <sect2 id='sysv'>
  156. <title>Selecting a Boot Method</title>
  157. <para>Selecting a boot method in LFS is relatively easy.
  158. Both systems are installed side-by-side. The only task needed is to
  159. ensure the files that are needed by the system have the correct names.
  160. The following scripts do that.</para>
  161. <screen><userinput remap="install">cat &gt; /usr/sbin/set-systemd &lt;&lt; "EOF"
  162. #! /bin/bash
  163. ln -svfn init-systemd /sbin/init
  164. ln -svfn init.d-systemd /etc/init.d
  165. for tool in halt poweroff reboot runlevel shutdown telinit; do
  166. ln -sfvn ${tool}-systemd /sbin/${tool}
  167. ln -svfn ${tool}-systemd.8 /usr/share/man/man8/${tool}.8
  168. done
  169. echo "Now reboot with /sbin/reboot-sysv"
  170. EOF
  171. chmod 0744 /usr/sbin/set-systemd
  172. cat &gt; /usr/sbin/set-sysv &lt;&lt; "EOF"
  173. #! /bin/bash
  174. ln -sfvn init-sysv /sbin/init
  175. ln -svfn init.d-sysv /etc/init.d
  176. for tool in halt poweroff reboot runlevel shutdown telinit; do
  177. ln -sfvn ${tool}-sysv /sbin/${tool}
  178. ln -svfn ${tool}-sysv.8 /usr/share/man/man8/${tool}.8
  179. done
  180. echo "Now reboot with /sbin/reboot-systemd"
  181. EOF
  182. chmod 0744 /usr/sbin/set-sysv</userinput></screen>
  183. <note><para>The comment about the correct command to reboot in the
  184. above scripts is correct. The reboot command for the current boot
  185. system must be used after the script changes the default reboot command.
  186. </para></note>
  187. <para>Now set the desired boot system. The default is System V:</para>
  188. <screen><userinput remap="install">/usr/sbin/set-sysv</userinput></screen>
  189. <para>Changing the boot system can be done at any time by running the
  190. appropriate script above and rebooting.</para>
  191. </sect2>
  192. -->
  193. </sect1>