source: chapter07/usage.xml@ fe3130a

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 6.3 6.4 6.5 6.6 6.7 6.8 7.0 7.1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since fe3130a was 81fd230, checked in by Gerard Beekmans <gerard@…>, 19 years ago

Trunk is now identical to Testing

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

  • Property mode set to 100644
File size: 5.1 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/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<para>The real scripts are in <filename
60class="directory">/etc/rc.d/init.d</filename>. They do the actual
61work, and the symlinks all point to them. Killing links and starting
62links point to the same script in <filename
63class="directory">/etc/rc.d/init.d</filename>. This is because the
64scripts can be called with different parameters like
65<parameter>start</parameter>, <parameter>stop</parameter>,
66<parameter>restart</parameter>, <parameter>reload</parameter>, and
67<parameter>status</parameter>. When a K link is encountered, the
68appropriate script is run with the <parameter>stop</parameter>
69argument. When an S link is encountered, the appropriate script is run
70with the <parameter>start</parameter> argument.</para>
71
72<para>There is one exception to this explanation. Links that start
73with an <emphasis>S</emphasis> in the <filename
74class="directory">rc0.d</filename> and <filename
75class="directory">rc6.d</filename> directories will not cause anything
76to be started. They will be called with the parameter
77<parameter>stop</parameter> to stop something. The logic behind this
78is that when a user is going to reboot or halt the system, nothing
79needs to be started. The system only needs to be stopped.</para>
80
81<para>These are descriptions of what the arguments make the scripts
82do:</para>
83
84<variablelist>
85<varlistentry>
86<term><parameter>start</parameter></term>
87<listitem><para>The service is started.</para></listitem>
88</varlistentry>
89
90<varlistentry>
91<term><parameter>stop</parameter></term>
92<listitem><para>The service is stopped.</para></listitem>
93</varlistentry>
94
95<varlistentry>
96<term><parameter>restart</parameter></term>
97<listitem><para>The service is stopped and then started again.</para></listitem>
98</varlistentry>
99
100<varlistentry>
101<term><parameter>reload</parameter></term>
102<listitem><para>The configuration of the service is updated.
103This is used after the configuration file of a service was modified, when
104the service does not need to be restarted.</para></listitem>
105</varlistentry>
106
107<varlistentry>
108<term><parameter>status</parameter></term>
109<listitem><para>Tells if the service is running and with which PIDs.</para></listitem>
110</varlistentry>
111</variablelist>
112
113<para>Feel free to modify the way the boot process works (after all,
114it is your own LFS system). The files given here are an example of how
115it can be done.</para>
116
117</sect1>
118
Note: See TracBrowser for help on using the repository browser.