1 | <?xml version="1.0" encoding="ISO-8859-1"?> |
---|
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 | |
---|
8 | <sect1 id="ch-scripts-usage"> |
---|
9 | <?dbhtml filename="usage.html"?> |
---|
10 | |
---|
11 | <title>How does Systemd work?</title> |
---|
12 | |
---|
13 | <indexterm zone="ch-scripts-usage"> |
---|
14 | <primary sortas="a-systemd-usage">Systemd usage</primary> |
---|
15 | <secondary>usage</secondary></indexterm> |
---|
16 | |
---|
17 | <warning> |
---|
18 | <para>Please disregard this page until it can be written.</para> |
---|
19 | </warning> |
---|
20 | <!-- |
---|
21 | <para>Linux uses a special booting facility named SysVinit that is |
---|
22 | based on a concept of <emphasis>run-levels</emphasis>. It can be quite |
---|
23 | different from one system to another, so it cannot be assumed that |
---|
24 | because things worked in one particular Linux distribution, they should work |
---|
25 | the same in CLFS too. CLFS has its own way of doing things, but it |
---|
26 | respects generally accepted standards.</para> |
---|
27 | |
---|
28 | <para>SysVinit (which will be referred to as <quote>init</quote> from |
---|
29 | now on) works using a run-levels scheme. There are seven (numbered 0 to 6) |
---|
30 | run-levels (actually, there are more run-levels, but they are for |
---|
31 | special cases and are generally not used. See <filename>init(8)</filename> |
---|
32 | for more details), and each one of those corresponds to the actions the |
---|
33 | computer is supposed to perform when it starts up. The default |
---|
34 | run-level is 3. Here are the descriptions of the different run-levels |
---|
35 | as they are implemented:</para> |
---|
36 | |
---|
37 | <literallayout>0: halt the computer |
---|
38 | 1: single-user mode |
---|
39 | 2: multi-user mode without networking |
---|
40 | 3: multi-user mode with networking |
---|
41 | 4: reserved for customization, otherwise does the same as 3 |
---|
42 | 5: same as 4, it is usually used for GUI login (like X's <command>xdm</command> or KDE's <command>kdm</command>) |
---|
43 | 6: reboot the computer</literallayout> |
---|
44 | |
---|
45 | <para>The command used to change run-levels is <command>init |
---|
46 | <replaceable>[runlevel]</replaceable></command>, where |
---|
47 | <replaceable>[runlevel]</replaceable> is the target run-level. For example, |
---|
48 | to reboot the computer, a user could issue the <command>init 6</command> |
---|
49 | command, which is an alias for the <command>reboot</command> command. |
---|
50 | Likewise, <command>init 0</command> is an alias for the |
---|
51 | <command>halt</command> command.</para> |
---|
52 | |
---|
53 | <para>There are a number of directories under <filename |
---|
54 | class="directory">/etc/rc.d</filename> that look like <filename |
---|
55 | class="directory">rc?.d</filename> (where ? is the number of the |
---|
56 | run-level) and <filename class="directory">rcsysinit.d</filename>, all |
---|
57 | containing a number of symbolic links. Some begin with a |
---|
58 | <emphasis>K</emphasis>, the others begin with an |
---|
59 | <emphasis>S</emphasis>, and all of them have two numbers following the |
---|
60 | initial letter. The K means to stop (kill) a service and the S means |
---|
61 | to start a service. The numbers determine the order in which the |
---|
62 | scripts are run, from 00 to 99—the lower the number the earlier it |
---|
63 | gets executed. When <command>init</command> switches to another run-level, |
---|
64 | the appropriate services are either started or stopped, depending on the |
---|
65 | runlevel chosen.</para> |
---|
66 | |
---|
67 | <para>The real scripts are in <filename |
---|
68 | class="directory">/etc/rc.d/init.d</filename>. They do the actual work, |
---|
69 | and the symlinks all point to them. Killing links and starting links point |
---|
70 | to the same script in <filename class="directory">/etc/rc.d/init.d</filename>. |
---|
71 | This is because the scripts can be called with different parameters like |
---|
72 | <option>start</option>, <option>stop</option>, <option>restart</option>, |
---|
73 | <option>reload</option>, and <option>status</option>. When a K link is |
---|
74 | encountered, the appropriate script is run with the <option>stop</option> |
---|
75 | argument. When an S link is encountered, the appropriate script is run |
---|
76 | with the <option>start</option> argument.</para> |
---|
77 | |
---|
78 | <para>There is one exception to this explanation. Links that start |
---|
79 | with an <emphasis>S</emphasis> in the <filename |
---|
80 | class="directory">rc0.d</filename> and <filename |
---|
81 | class="directory">rc6.d</filename> directories will not cause anything |
---|
82 | to be started. They will be called with the parameter |
---|
83 | <option>stop</option> to stop something. The logic behind this |
---|
84 | is that when a user is going to reboot or halt the system, nothing |
---|
85 | needs to be started. The system only needs to be stopped.</para> |
---|
86 | |
---|
87 | <para>These are descriptions of what the arguments make the scripts |
---|
88 | do:</para> |
---|
89 | |
---|
90 | <variablelist> |
---|
91 | <varlistentry> |
---|
92 | <term><option>start</option></term> |
---|
93 | <listitem> |
---|
94 | <para>The service is started.</para> |
---|
95 | </listitem> |
---|
96 | </varlistentry> |
---|
97 | |
---|
98 | <varlistentry> |
---|
99 | <term><option>stop</option></term> |
---|
100 | <listitem> |
---|
101 | <para>The service is stopped.</para> |
---|
102 | </listitem> |
---|
103 | </varlistentry> |
---|
104 | |
---|
105 | <varlistentry> |
---|
106 | <term><option>restart</option></term> |
---|
107 | <listitem> |
---|
108 | <para>The service is stopped and then started again.</para> |
---|
109 | </listitem> |
---|
110 | </varlistentry> |
---|
111 | |
---|
112 | <varlistentry> |
---|
113 | <term><option>reload</option></term> |
---|
114 | <listitem> |
---|
115 | <para>The configuration of the service is updated. This is used |
---|
116 | after the configuration file of a service was modified, when the |
---|
117 | service does not need to be restarted.</para> |
---|
118 | </listitem> |
---|
119 | </varlistentry> |
---|
120 | |
---|
121 | <varlistentry> |
---|
122 | <term><option>status</option></term> |
---|
123 | <listitem> |
---|
124 | <para>Tells if the service is running and with which PIDs.</para> |
---|
125 | </listitem> |
---|
126 | </varlistentry> |
---|
127 | </variablelist> |
---|
128 | |
---|
129 | <para>Feel free to modify the way the boot process works (after all, |
---|
130 | it is your own CLFS system). The files given here are an example of how |
---|
131 | it can be done.</para> |
---|
132 | --> |
---|
133 | |
---|
134 | </sect1> |
---|