usage.xml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
  3. <!ENTITY % general-entities SYSTEM "../general.ent">
  4. %general-entities;
  5. ]>
  6. <sect1 id="ch-scripts-usage">
  7. <title>How does the booting process with these scripts work?</title>
  8. <?dbhtml filename="usage.html"?>
  9. <indexterm zone="ch-scripts-usage">
  10. <primary sortas="a-Bootscripts">Bootscripts</primary>
  11. <secondary>usage</secondary></indexterm>
  12. <para>Linux uses a special booting facility named SysVinit. It's based on a
  13. concept of <emphasis>run-levels</emphasis>. It can be widely different
  14. from one system to another, so it can't be assumed that because things
  15. worked in &lt;insert distro name&gt; they should work like that in LFS
  16. too. LFS has its own way of doing things, but it respects generally
  17. accepted standards.</para>
  18. <para>SysVinit (which we'll call <emphasis>init</emphasis> from now on) works
  19. using a run-levels scheme. There are 7 (from 0 to 6) run-levels
  20. (actually, there are more run-levels but they are for special cases and
  21. generally not used. The init man page describes those details), and each
  22. one of those corresponds to the things the computer is supposed to do when
  23. it starts up. The default run-level is 3. Here are the descriptions of the
  24. different run-levels as they are often implemented:</para>
  25. <literallayout>0: halt the computer
  26. 1: single-user mode
  27. 2: multi-user mode without networking
  28. 3: multi-user mode with networking
  29. 4: reserved for customization, otherwise does the same as 3
  30. 5: same as 4, it is usually used for GUI login (like X's xdm or KDE's kdm)
  31. 6: reboot the computer</literallayout>
  32. <para>The command used to change run-levels is <command>init
  33. &lt;runlevel&gt;</command> where &lt;runlevel&gt; is the target run-level. For
  34. example, to reboot the computer, a user would issue the <command>init
  35. 6</command> command. The <command>reboot</command> command is just an alias for
  36. it, as is the <command>halt</command> command an alias for <command>init
  37. 0</command>.</para>
  38. <para>There are a number of directories under <filename>/etc/rc.d</filename>
  39. that look like like rc?.d (where ? is the number of the run-level) and rcsysinit.d
  40. all containing a number of symbolic links. Some begin with a K, the others begin
  41. with an S, and all of them have two numbers following the initial letter. The K
  42. means to stop (kill) a service, and the S means to start a service. The numbers
  43. determine the order in which the scripts are run, from 00 to 99; the lower the
  44. number the sooner it gets executed. When init switches to another run-level, the
  45. appropriate services get killed and others get started.</para>
  46. <para>The real scripts are in /etc/rc.d/init.d. They do all the work, and the
  47. symlinks all point to them. Killing links and starting links point to
  48. the same script in /etc/rc.d/init.d. That's because the scripts can be
  49. called with different parameters like start, stop, restart, reload,
  50. status. When a K link is encountered, the appropriate script is run with
  51. the stop argument. When an S link is encountered, the appropriate script
  52. is run with the start argument.</para>
  53. <para>There is one exception. Links that start with an S in the
  54. rc0.d and rc6.d directories will not cause anything to be started. They
  55. will be called with the parameter <emphasis>stop</emphasis> to stop
  56. something. The logic behind it is that when you are going to reboot or
  57. halt the system, you don't want to start anything, only stop the
  58. system.</para>
  59. <para>These are descriptions of what the arguments make the
  60. scripts do:</para>
  61. <itemizedlist>
  62. <listitem><para><emphasis>start</emphasis>: The service is
  63. started.</para></listitem>
  64. <listitem><para><emphasis>stop</emphasis>: The service is
  65. stopped.</para></listitem>
  66. <listitem><para><emphasis>restart</emphasis>: The service is
  67. stopped and then started again.</para></listitem>
  68. <listitem><para><emphasis>reload</emphasis>: The configuration
  69. of the service is updated.
  70. This is used after the configuration file of a service was modified, when
  71. the service doesn't need to be restarted.</para></listitem>
  72. <listitem><para><emphasis>status</emphasis>: Tells if the service
  73. is running and with which PIDs.</para></listitem>
  74. </itemizedlist>
  75. <para>Feel free to modify the way the boot process works (after all, it's your
  76. own LFS system). The files given here are just an example of how it can be
  77. done in a nice way (well, what we consider nice -- you may hate it).</para>
  78. </sect1>