usage.xml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <sect1 id="ch07-usage">
  2. <title>How does the booting process with these scripts work?</title>
  3. <para>
  4. Linux uses a special booting facility named SysVinit. It's based on a
  5. concept of <emphasis>runlevels</emphasis>. It can be widely different
  6. from one system to another, so it can not be assumed that because things
  7. worked in &lt;insert distro name&gt; they should work like that in LFS
  8. too. LFS has it's own way of doing things, but it respects generally
  9. accepted standards.
  10. </para>
  11. <para>
  12. SysVinit (which we'll call <emphasis>init</emphasis> from now on) works
  13. using a runlevels scheme. There are 7 (from 0 to 6) runlevels
  14. (actually, there are more runlevels but they are for special cases and
  15. generally not used. The init man page describes those details), and each
  16. one of those corresponds to the things the computer is supposed to do when
  17. it starts up. The default runlevel is 3. Here are the descriptions of the
  18. different runlevels as they are often implemented:
  19. </para>
  20. <literallayout>
  21. 0: halt the computer
  22. 1: single-user mode
  23. 2: multi-user mode without networking
  24. 3: multi-user mode with networking
  25. 4: reserved for customization, otherwise does the same as 3
  26. 5: same as 4, it is usually used for GUI login (like X's xdm or KDE's kdm)
  27. 6: reboot the computer
  28. </literallayout>
  29. <para>
  30. The command used to change runlevels is <userinput>init
  31. &lt;runlevel&gt;</userinput> where &lt;runlevel&gt; is
  32. the target runlevel. For example, to reboot the computer, a user would issue
  33. the init 6 command. The reboot command is just an alias, as is the halt
  34. command an alias to init 0.
  35. </para>
  36. <para>
  37. The /etc/init.d/rcS script is run at every startup of the computer,
  38. before any runlevel is executed and runs the scripts listed in
  39. /etc/rcS.d
  40. </para>
  41. <para>
  42. There are a number of directories under /etc that look like like rc?.d
  43. where ? is the number of the runlevel and rcS.d. A user might take a look
  44. at one of
  45. them (after this chapter is finished, right now there's nothing
  46. there yet). There are a number of symbolic links. Some begin with an K,
  47. the others begin with an S, and all of them have three numbers following
  48. the initial letter. The K means to stop (kill) a service, and the S means
  49. to start a service. The numbers determine the order in which the scripts
  50. are run, from 000 to 999; the lower the number the sooner it gets
  51. executed. When init switches to another runlevel, the appropriate
  52. services get killed and others get started.
  53. </para>
  54. <para>
  55. The real scripts are in /etc/init.d. They do all the work, and the
  56. symlinks all point to them. Killing links and starting
  57. links point to the same script in /etc/init.d. That's because the scripts
  58. can be called with different parameters like start, stop, restart, reload,
  59. status. When a K link is encountered, the appropriate script is run with
  60. the stop argument. When a S link is encountered, the appropriate script
  61. is run with the start argument.
  62. </para>
  63. <para>
  64. These are descriptions of what the arguments make the scripts do:
  65. </para>
  66. <itemizedlist>
  67. <listitem><para>
  68. <emphasis>start</emphasis>: The service is started.
  69. </para></listitem>
  70. <listitem><para>
  71. <emphasis>stop</emphasis>: The service is stopped.
  72. </para></listitem>
  73. <listitem><para>
  74. <emphasis>restart</emphasis>: The service is stopped and then started again.
  75. </para></listitem>
  76. <listitem><para>
  77. <emphasis>reload</emphasis>: The configuration of the service is updated.
  78. This is used after the configuration file of a service was modified, when
  79. the service doesn't need to be restarted.
  80. </para></listitem>
  81. <listitem><para>
  82. <emphasis>status</emphasis>: Tells if the service is running and with
  83. which PID's.
  84. </para></listitem>
  85. </itemizedlist>
  86. <para>
  87. Feel free to modify the way the boot process works (after all it's your
  88. LFS system, not ours). The files here are just an example of how it can be
  89. done in a nice way (well what we consider nice anyway. You may hate it).
  90. </para>
  91. </sect1>