usage.xml 3.8 KB

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