source: chapter07/usage.xml@ 38bb44a

6.0
Last change on this file since 38bb44a was 38bb44a, checked in by Gerard Beekmans <gerard@…>, 20 years ago

first round of printed layout fixes

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/testing/BOOK@4155 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

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