usage.xml 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 don't assume 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 (actually
  14. there are runlevels but they are for special cases and generally not used.
  15. Read the init man page for those details), and each one of those
  16. corresponds to the things you want your computer to do when it starts
  17. up. The default runlevel is 3. Here are the descriptions of the different
  18. 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
  27. kdm)
  28. 6: reboot the computer
  29. </literallayout>
  30. <para>
  31. The command used to change runlevels is <userinput>init
  32. &lt;runlevel&gt;</userinput> where &lt;runlevel>&gt; is
  33. the target runlevel. For example, to reboot the computer, you'd issue
  34. the init 6 command. The reboot command is just an alias, as is the halt
  35. command an alias to init 0.
  36. </para>
  37. <para>
  38. The /etc/init.d/rcS script is run at every startup of the computer,
  39. before any runlevel is executed and runs the scripts listed in
  40. /etc/rcS.d
  41. </para>
  42. <para>
  43. There are a number of directories under /etc that look like like rc?.d
  44. where ? is the number of the runlevel and rcS.d. Take a look at one of
  45. them (after you finish this chapter that is, 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. You'll note that 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. <literallayout>
  64. These are descriptions of what the arguments make the scripts do:
  65. <emphasis>start</emphasis>: The service is started.
  66. <emphasis>stop</emphasis>: The service is stopped.
  67. <emphasis>restart</emphasis>: The service is stopped and then started again.
  68. <emphasis>reload</emphasis>: The configuration of the service is updated.
  69. Use this after you have modified the configuration file of a service, when
  70. you don't need/want to restart the service.
  71. <emphasis>status</emphasis>: Tells you if the service is running and with
  72. which PID's
  73. </literallayout>
  74. <para>
  75. Feel free to modify the way the boot process works (after all it's your
  76. LFS system, not ours). The files here are just an example of how you
  77. can do it in a nice way (well what we consider nice anyway. You may
  78. hate it).
  79. </para>
  80. </sect1>