chiark / gitweb /
Make initrd.target the default target in the initrd
[elogind.git] / man / bootup.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3         "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6   This file is part of systemd.
7
8   Copyright 2012 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="bootup">
25
26         <refentryinfo>
27                 <title>bootup</title>
28                 <productname>systemd</productname>
29
30                 <authorgroup>
31                         <author>
32                                 <contrib>Developer</contrib>
33                                 <firstname>Lennart</firstname>
34                                 <surname>Poettering</surname>
35                                 <email>lennart@poettering.net</email>
36                         </author>
37                 </authorgroup>
38         </refentryinfo>
39
40         <refmeta>
41                 <refentrytitle>bootup</refentrytitle>
42                 <manvolnum>7</manvolnum>
43         </refmeta>
44
45         <refnamediv>
46                 <refname>bootup</refname>
47                 <refpurpose>System bootup process</refpurpose>
48         </refnamediv>
49
50         <refsect1>
51                 <title>Description</title>
52
53                 <para>A number of different components are involved in the
54                 system boot. Immediately after power-up, the system
55                 BIOS will do minimal hardware initialization, and hand
56                 control over to a boot loader stored on a persistent
57                 storage device. This boot loader will then invoke an
58                 OS kernel from disk (or the network). In the Linux
59                 case this kernel now (optionally) extracts and
60                 executes an initial RAM disk image (initrd) such as
61                 <citerefentry><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>
62                 which looks for the root file system. After the root
63                 file system is found and mounted the initrd hands over
64                 control to the system manager (such as
65                 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
66                 stored on the OS image which is then responsible for
67                 probing all remaining hardware, mounting all necessary
68                 file systems and spawning all configured
69                 services.</para>
70
71                 <para>On shutdown the system manager stops all
72                 services, unmounts all file systems (detaching the
73                 storage technologies backing them), and then
74                 (optionally) jumps back into the initrd code which
75                 unmounts/detaches the root file system and the storage
76                 it resides on. As last step the system is powered down.</para>
77
78                 <para>Additional information about the system boot
79                 process may be found in
80                 <citerefentry><refentrytitle>boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
81         </refsect1>
82
83         <refsect1>
84                 <title>System Manager Bootup</title>
85
86                 <para>At boot, the system manager on the OS image is
87                 responsible for initializing the required file
88                 systems, services and drivers that are necessary for
89                 operation of the system. On
90                 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
91                 systems this process is split up in various discrete
92                 steps which are exposed as target units. (See
93                 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>
94                 for detailed information about target units.) The
95                 boot-up process is highly parallelized so that the
96                 order in which specific target units are reached is not
97                 deterministic, but still adheres to a limited amount
98                 of ordering structure.</para>
99
100                 <para>When systemd starts up the system it will
101                 activate all units that are dependencies of
102                 <filename>default.target</filename> (as well as
103                 recursively all dependencies of these
104                 dependencies). Usually
105                 <filename>default.target</filename> is simply an alias
106                 of <filename>graphical.target</filename> or
107                 <filename>multi-user.target</filename> depending on
108                 whether the system is configured for a graphical UI or
109                 only for a text console. To enforce minimal ordering
110                 between the units pulled in a number of well-known
111                 target units are available, as listed on
112                 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
113
114                 <para>The following chart is a structural overview of
115                 these well-known units and their position in the
116                 boot-up logic. The arrows describe which units are
117                 pulled in and ordered before which other units. Units
118                 near the top are started before units nearer to the
119                 bottom of the chart.</para>
120
121 <programlisting>local-fs-pre.target
122          |
123          v
124 (various mounts and   (various swap   (various cryptsetup
125  fsck services...)     devices...)        devices...)       (various low-level   (various low-level
126          |                  |                  |             services: udevd,     API VFS mounts:
127          v                  v                  v             tmpfiles, random     mqueue, configfs,
128   local-fs.target      swap.target     cryptsetup.target    seed, sysctl, ...)      debugfs, ...)
129          |                  |                  |                    |                    |
130          \__________________|_________________ | ___________________|____________________/
131                                               \|/
132                                                v
133                                         sysinit.target
134                                                |
135                              _________________/|\___________________
136                             /                  |                    \
137                             |                  |                    |
138                             v                  |                    v
139                         (various               |              rescue.service
140                        sockets...)             |                    |
141                             |                  |                    v
142                             v                  |              <emphasis>rescue.target</emphasis>
143                      sockets.target            |
144                             |                  |
145                             \_________________ |
146                                               \|
147                                                v
148                                          basic.target
149                                                |
150             __________________________________/|                                 emergency.service
151            /                |                  |                                         |
152            |                |                  |                                         v
153            v                v                  v                                 <emphasis>emergency.target</emphasis>
154        display-      (various system    (various system
155    manager.service       services           services)
156            |           required for            |
157            |          graphical UIs)           v
158            |                |           <emphasis>multi-user.target</emphasis>
159            |                |                  |
160            \_______________ | _________________/
161                            \|/
162                             v
163                     <emphasis>graphical.target</emphasis></programlisting>
164
165                 <para>Target units that are commonly used as boot
166                 targets are <emphasis>emphasized</emphasis>. These
167                 units are good choices as goal targets, for
168                 example by passing them to the
169                 <varname>systemd.unit=</varname> kernel command line
170                 option (see
171                 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
172                 or by symlinking <filename>default.target</filename>
173                 to them.</para>
174         </refsect1>
175
176         <refsect1>
177                 <title>Systemd in the Initrd</title>
178                 <para>If the initrd creation tool used the services provided
179                 by systemd, the default target in the initrd is the
180                 initrd-fs.target. The process is the same as above until the basic.target is reached.
181                 Systemd now continues to the initrd.target. If the root device could be mounted
182                 on /sysroot, the sysroot.mount unit is active and the initrd-root-fs.target is reached.
183                 initrd-parse-etc.service scans /sysroot/etc/fstab for the /usr mountpoint and for entries
184                 marked with the <emphasis>x-initrd.mount</emphasis> option set. If these mountpoint are
185                 mounted in /sysroot, the initrd-fs.target is reached.
186                 The initrd-cleanup.service isolates to the initrd-switch-root.target,
187                 where cleanup services can run. At the very last end
188                 initrd-switch-root.service is activated, which will cause
189                 the system to switch root to /sysroot.
190                 </para>
191
192 <programlisting>
193                                         (same as above)
194                                                :
195                                                :
196                                                v
197                                          basic.target
198                                                |                                 emergency.service
199                         ______________________/|                                         |
200                        /                       |                                         v
201                        |                  sysroot.mount                          <emphasis>emergency.target</emphasis>
202                        |                       |
203                        |                       v
204                        |             initrd-root-fs.target
205                        |                       |
206                        |                       v
207                        |            initrd-parse-etc.service
208            (custom initrd services)            |
209                        |                       v
210                        |            (sysroot-usr.mount and
211                        |             various mounts marked
212                        |               with fstab option
213                        |                x-initrd.mount)
214                        |                       |
215                        |                       v
216                        |                initrd-fs.target
217                        |                       |
218                        \______________________ |
219                                               \|
220                                                v
221                                           initrd.target
222                                                |
223                                                v
224                                      initrd-cleanup.service
225                                           isolates to
226                                     initrd-switch-root.target
227                                                |
228                                                v
229                         ______________________/|
230                        /                       |
231                        |        initrd-udevadm-cleanup-db.service
232                        |                       |
233            (custom initrd services)            |
234                        |                       |
235                        \______________________ |
236                                               \|
237                                                v
238                                    initrd-switch-root.target
239                                                |
240                                                v
241                                    initrd-switch-root.service
242                                                |
243                                                v
244                                           switch-root
245 </programlisting>
246         </refsect1>
247
248
249         <refsect1>
250                 <title>System Manager Shutdown</title>
251
252                 <para>System shutdown also consists of various target
253                 units with some minimal ordering structure
254                 applied:</para>
255
256
257
258
259 <programlisting>                                  (conflicts with  (conflicts with
260                                     all system     all file system
261                                      services)     mounts, swaps,
262                                          |           cryptsetup
263                                          |          devices, ...)
264                                          |                |
265                                          v                v
266                                   shutdown.target    umount.target
267                                          |                |
268                                          \_______   ______/
269                                                  \ /
270                                                   v
271                                          (various low-level
272                                               services)
273                                                   |
274                                                   v
275                                             final.target
276                                                   |
277             _____________________________________/ \_________________________________
278            /                         |                        |                      \
279            |                         |                        |                      |
280            v                         v                        v                      v
281 systemd-reboot.service   systemd-poweroff.service   systemd-halt.service   systemd-kexec.service
282            |                         |                        |                      |
283            v                         v                        v                      v
284     <emphasis>reboot.target</emphasis>             <emphasis>poweroff.target</emphasis>            <emphasis>halt.target</emphasis>           <emphasis>kexec.target</emphasis></programlisting>
285
286                 <para>Commonly used system shutdown targets are <emphasis>emphasized</emphasis>.</para>
287         </refsect1>
288
289         <refsect1>
290                 <title>See Also</title>
291                 <para>
292                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
293                         <citerefentry><refentrytitle>boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
294                         <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
295                         <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
296                         <citerefentry><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>
297                 </para>
298         </refsect1>
299
300 </refentry>