[673b0d8] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[1770019] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
|
---|
[673b0d8] | 3 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 4 | %general-entities;
|
---|
| 5 | ]>
|
---|
[3be4d97] | 6 | <sect1 id="ch-scripts-usage">
|
---|
[bce08ef] | 7 | <title>How Do These Bootscripts Work?</title>
|
---|
[673b0d8] | 8 | <?dbhtml filename="usage.html"?>
|
---|
| 9 |
|
---|
[81fd230] | 10 | <indexterm zone="ch-scripts-usage">
|
---|
| 11 | <primary sortas="a-Bootscripts">Bootscripts</primary>
|
---|
| 12 | <secondary>usage</secondary></indexterm>
|
---|
[0ad6d9a] | 13 |
|
---|
[81fd230] | 14 | <para>Linux uses a special booting facility named SysVinit that is
|
---|
| 15 | based on a concept of <emphasis>run-levels</emphasis>. It can be quite
|
---|
| 16 | different from one system to another, so it cannot be assumed that
|
---|
| 17 | because things worked in <insert distro name>, they should work
|
---|
| 18 | the same in LFS too. LFS has its own way of doing things, but it
|
---|
| 19 | respects generally accepted standards.</para>
|
---|
| 20 |
|
---|
| 21 | <para>SysVinit (which will be referred to as <quote>init</quote> from
|
---|
| 22 | now on) works using a run-levels scheme. There are seven (from 0 to 6)
|
---|
| 23 | run-levels (actually, there are more run-levels, but they are for
|
---|
| 24 | special cases and are generally not used. The init man page describes
|
---|
| 25 | those details), and each one of those corresponds to the actions the
|
---|
| 26 | computer is supposed to perform when it starts up. The default
|
---|
| 27 | run-level is 3. Here are the descriptions of the different run-levels
|
---|
| 28 | as they are implemented:</para>
|
---|
| 29 |
|
---|
| 30 | <literallayout>0: halt the computer
|
---|
| 31 | 1: single-user mode
|
---|
| 32 | 2: multi-user mode without networking
|
---|
| 33 | 3: multi-user mode with networking
|
---|
| 34 | 4: reserved for customization, otherwise does the same as 3
|
---|
| 35 | 5: same as 4, it is usually used for GUI login (like X's <command>xdm</command> or KDE's <command>kdm</command>)
|
---|
| 36 | 6: 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
|
---|
| 41 | example, to reboot the computer, a user would issue the <command>init
|
---|
| 42 | 6</command> command. The <command>reboot</command> command is an
|
---|
| 43 | alias 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
|
---|
| 47 | class="directory">/etc/rc.d</filename> that look like <filename
|
---|
| 48 | class="directory">rc?.d</filename> (where ? is the number of the
|
---|
| 49 | run-level) and <filename class="directory">rcsysinit.d</filename>, all
|
---|
| 50 | containing 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
|
---|
| 53 | initial letter. The K means to stop (kill) a service and the S means
|
---|
| 54 | to start a service. The numbers determine the order in which the
|
---|
| 55 | scripts are run, from 00 to 99—the lower the number the earlier it
|
---|
| 56 | gets executed. When init switches to another run-level, the
|
---|
| 57 | appropriate services get killed and others get started.</para>
|
---|
| 58 |
|
---|
| 59 | <para>The real scripts are in <filename
|
---|
| 60 | class="directory">/etc/rc.d/init.d</filename>. They do the actual
|
---|
| 61 | work, and the symlinks all point to them. Killing links and starting
|
---|
| 62 | links point to the same script in <filename
|
---|
| 63 | class="directory">/etc/rc.d/init.d</filename>. This is because the
|
---|
| 64 | scripts 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
|
---|
| 68 | appropriate script is run with the <parameter>stop</parameter>
|
---|
| 69 | argument. When an S link is encountered, the appropriate script is run
|
---|
| 70 | with the <parameter>start</parameter> argument.</para>
|
---|
| 71 |
|
---|
| 72 | <para>There is one exception to this explanation. Links that start
|
---|
| 73 | with an <emphasis>S</emphasis> in the <filename
|
---|
| 74 | class="directory">rc0.d</filename> and <filename
|
---|
| 75 | class="directory">rc6.d</filename> directories will not cause anything
|
---|
| 76 | to be started. They will be called with the parameter
|
---|
| 77 | <parameter>stop</parameter> to stop something. The logic behind this
|
---|
| 78 | is that when a user is going to reboot or halt the system, nothing
|
---|
| 79 | needs to be started. The system only needs to be stopped.</para>
|
---|
| 80 |
|
---|
| 81 | <para>These are descriptions of what the arguments make the scripts
|
---|
| 82 | do:</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.
|
---|
| 103 | This is used after the configuration file of a service was modified, when
|
---|
| 104 | the 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,
|
---|
| 114 | it is your own LFS system). The files given here are an example of how
|
---|
| 115 | it can be done.</para>
|
---|
[0ad6d9a] | 116 |
|
---|
| 117 | </sect1>
|
---|
[81fd230] | 118 |
|
---|