]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/bootup.xml
Merge pull request #8676 from keszybz/drop-license-boilerplate
[thirdparty/systemd.git] / man / bootup.xml
CommitLineData
013d8a39
LP
1<?xml version='1.0'?> <!--*-nxml-*-->
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
12b42c76 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
013d8a39
LP
4
5<!--
572eb058
ZJS
6 SPDX-License-Identifier: LGPL-2.1+
7
013d8a39
LP
8 This file is part of systemd.
9
10 Copyright 2012 Lennart Poettering
013d8a39
LP
11-->
12
13<refentry id="bootup">
14
798d3a52
ZJS
15 <refentryinfo>
16 <title>bootup</title>
17 <productname>systemd</productname>
18
19 <authorgroup>
20 <author>
21 <contrib>Developer</contrib>
22 <firstname>Lennart</firstname>
23 <surname>Poettering</surname>
24 <email>lennart@poettering.net</email>
25 </author>
26 </authorgroup>
27 </refentryinfo>
28
29 <refmeta>
30 <refentrytitle>bootup</refentrytitle>
31 <manvolnum>7</manvolnum>
32 </refmeta>
33
34 <refnamediv>
35 <refname>bootup</refname>
36 <refpurpose>System bootup process</refpurpose>
37 </refnamediv>
38
39 <refsect1>
40 <title>Description</title>
41
42 <para>A number of different components are involved in the system
43 boot. Immediately after power-up, the system BIOS will do minimal
44 hardware initialization, and hand control over to a boot loader
45 stored on a persistent storage device. This boot loader will then
46 invoke an OS kernel from disk (or the network). In the Linux case,
47 this kernel (optionally) extracts and executes an initial RAM disk
48 image (initrd), such as generated by
49 <citerefentry project='die-net'><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
50 which looks for the root file system (possibly using
51 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
52 for this). After the root file system is found and mounted, the
53 initrd hands over control to the host's system manager (such as
54 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
55 stored on the OS image, which is then responsible for probing all
56 remaining hardware, mounting all necessary file systems and
57 spawning all configured services.</para>
58
59 <para>On shutdown, the system manager stops all services, unmounts
60 all file systems (detaching the storage technologies backing
61 them), and then (optionally) jumps back into the initrd code which
62 unmounts/detaches the root file system and the storage it resides
63 on. As a last step, the system is powered down.</para>
64
65 <para>Additional information about the system boot process may be
66 found in
67 <citerefentry project='man-pages'><refentrytitle>boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
68 </refsect1>
69
70 <refsect1>
71 <title>System Manager Bootup</title>
72
73 <para>At boot, the system manager on the OS image is responsible
74 for initializing the required file systems, services and drivers
75 that are necessary for operation of the system. On
76 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
77 systems, this process is split up in various discrete steps which
78 are exposed as target units. (See
79 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>
80 for detailed information about target units.) The boot-up process
81 is highly parallelized so that the order in which specific target
82 units are reached is not deterministic, but still adheres to a
83 limited amount of ordering structure.</para>
84
85 <para>When systemd starts up the system, it will activate all
86 units that are dependencies of <filename>default.target</filename>
87 (as well as recursively all dependencies of these dependencies).
88 Usually, <filename>default.target</filename> is simply an alias of
89 <filename>graphical.target</filename> or
90 <filename>multi-user.target</filename>, depending on whether the
91 system is configured for a graphical UI or only for a text
92 console. To enforce minimal ordering between the units pulled in,
93 a number of well-known target units are available, as listed on
94 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
95
96 <para>The following chart is a structural overview of these
97 well-known units and their position in the boot-up logic. The
98 arrows describe which units are pulled in and ordered before which
99 other units. Units near the top are started before units nearer to
100 the bottom of the chart.</para>
013d8a39 101
24c44fdf
ZJS
102 <!-- note: do not use unicode ellipsis here, because docbook will replace that
103 with three dots anyway, messing up alignment -->
013d8a39 104<programlisting>local-fs-pre.target
72b7d998
ZJS
105 |
106 v
013d8a39 107(various mounts and (various swap (various cryptsetup
72b7d998
ZJS
108 fsck services...) devices...) devices...) (various low-level (various low-level
109 | | | services: udevd, API VFS mounts:
110 v v v tmpfiles, random mqueue, configfs,
013d8a39 111 local-fs.target swap.target cryptsetup.target seed, sysctl, ...) debugfs, ...)
72b7d998
ZJS
112 | | | | |
113 \__________________|_________________ | ___________________|____________________/
114 \|/
115 v
116 sysinit.target
117 |
118 ____________________________________/|\________________________________________
119 / | | | \
120 | | | | |
121 v v | v v
122 (various (various | (various rescue.service
123 timers...) paths...) | sockets...) |
124 | | | | v
125 v v | v <emphasis>rescue.target</emphasis>
126 timers.target paths.target | sockets.target
127 | | | |
b44787bd 128 v \_________________ | ___________________/
72b7d998
ZJS
129 \|/
130 v
131 basic.target
132 |
133 ____________________________________/| emergency.service
134 / | | |
135 | | | v
136 v v v <emphasis>emergency.target</emphasis>
137 display- (various system (various system
138 manager.service services services)
139 | required for |
140 | graphical UIs) v
141 | | <emphasis>multi-user.target</emphasis>
142 | | |
143 \_________________ | _________________/
144 \|/
145 v
146 <emphasis>graphical.target</emphasis></programlisting>
798d3a52
ZJS
147
148 <para>Target units that are commonly used as boot targets are
149 <emphasis>emphasized</emphasis>. These units are good choices as
150 goal targets, for example by passing them to the
151 <varname>systemd.unit=</varname> kernel command line option (see
152 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
72b7d998
ZJS
153 or by symlinking <filename>default.target</filename> to them.
154 </para>
798d3a52
ZJS
155
156 <para><filename>timers.target</filename> is pulled-in by
157 <filename>basic.target</filename> asynchronously. This allows
158 timers units to depend on services which become only available
159 later in boot.</para>
160 </refsect1>
161
162 <refsect1>
163 <title>Bootup in the Initial RAM Disk (initrd)</title>
164 <para>The initial RAM disk implementation (initrd) can be set up
165 using systemd as well. In this case, boot up inside the initrd
166 follows the following structure.</para>
167
168 <para>The default target in the initrd is
169 <filename>initrd.target</filename>. The bootup process begins
170 identical to the system manager bootup (see above) until it
171 reaches <filename>basic.target</filename>. From there, systemd
172 approaches the special target <filename>initrd.target</filename>.
6d9e45e9
JH
173
174 Before any file systems are mounted, it must be determined whether
175 the system will resume from hibernation or proceed with normal boot.
176 This is accomplished by <filename>systemd-hibernate-resume@.service</filename>
177 which must be finished before <filename>local-fs-pre.target</filename>,
178 so no filesystems can be mounted before the check is complete.
179
7163e1ca
DD
180 When the root device becomes available,
181 <filename>initd-root-device.target</filename> is reached.
798d3a52
ZJS
182 If the root device can be mounted at
183 <filename>/sysroot</filename>, the
184 <filename>sysroot.mount</filename> unit becomes active and
185 <filename>initrd-root-fs.target</filename> is reached. The service
186 <filename>initrd-parse-etc.service</filename> scans
187 <filename>/sysroot/etc/fstab</filename> for a possible
188 <filename>/usr</filename> mount point and additional entries
189 marked with the <emphasis>x-initrd.mount</emphasis> option. All
190 entries found are mounted below <filename>/sysroot</filename>, and
191 <filename>initrd-fs.target</filename> is reached. The service
192 <filename>initrd-cleanup.service</filename> isolates to the
193 <filename>initrd-switch-root.target</filename>, where cleanup
194 services can run. As the very last step, the
195 <filename>initrd-switch-root.service</filename> is activated,
196 which will cause the system to switch its root to
197 <filename>/sysroot</filename>.
198 </para>
199
72b7d998
ZJS
200<programlisting> : (beginning identical to above)
201 :
202 v
203 basic.target
204 | emergency.service
205 ______________________/| |
206 / | v
7163e1ca
DD
207 | initrd-root-device.target <emphasis>emergency.target</emphasis>
208 | |
209 | v
210 | sysroot.mount
72b7d998
ZJS
211 | |
212 | v
213 | initrd-root-fs.target
214 | |
215 | v
216 v initrd-parse-etc.service
217 (custom initrd |
218 services...) v
219 | (sysroot-usr.mount and
220 | various mounts marked
221 | with fstab option
222 | x-initrd.mount...)
223 | |
224 | v
225 | initrd-fs.target
226 \______________________ |
227 \|
228 v
229 initrd.target
230 |
231 v
232 initrd-cleanup.service
233 isolates to
234 initrd-switch-root.target
235 |
236 v
237 ______________________/|
238 / v
239 | initrd-udevadm-cleanup-db.service
240 v |
241 (custom initrd |
242 services...) |
243 \______________________ |
244 \|
245 v
246 initrd-switch-root.target
247 |
248 v
249 initrd-switch-root.service
250 |
251 v
252 Transition to Host OS</programlisting>
798d3a52
ZJS
253 </refsect1>
254
798d3a52
ZJS
255 <refsect1>
256 <title>System Manager Shutdown</title>
257
258 <para>System shutdown with systemd also consists of various target
259 units with some minimal ordering structure applied:</para>
260
72b7d998
ZJS
261<programlisting> (conflicts with (conflicts with
262 all system all file system
263 services) mounts, swaps,
264 | cryptsetup
265 | devices, ...)
266 | |
267 v v
268 shutdown.target umount.target
269 | |
270 \_______ ______/
271 \ /
272 v
273 (various low-level
274 services)
275 |
276 v
277 final.target
278 |
279 _____________________________________/ \_________________________________
280 / | | \
281 | | | |
282 v v v v
0e0320e0 283systemd-reboot.service systemd-poweroff.service systemd-halt.service systemd-kexec.service
72b7d998
ZJS
284 | | | |
285 v v v v
286 <emphasis>reboot.target</emphasis> <emphasis>poweroff.target</emphasis> <emphasis>halt.target</emphasis> <emphasis>kexec.target</emphasis></programlisting>
798d3a52 287
e799056e
LP
288 <para>Commonly used system shutdown targets are <emphasis>emphasized</emphasis>.</para>
289
290 <para>Note that
39e4f5bc 291 <citerefentry><refentrytitle>systemd-halt.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
e799056e
LP
292 <filename>systemd-reboot.service</filename>, <filename>systemd-poweroff.service</filename> and
293 <filename>systemd-kexec.service</filename> will transition the system and server manager (PID 1) into the second
294 phase of system shutdown (implemented in the <filename>systemd-shutdown</filename> binary), which will unmount any
295 remaining file systems, kill any remaining processes and release any other remaining resources, in a simple and
296 robust fashion, without taking any service or unit concept into account anymore. At that point, regular
297 applications and resources are generally terminated and released already, the second phase hence operates only as
298 safety net for everything that couldn't be stopped or released for some reason during the primary, unit-based
299 shutdown phase described above.</para>
798d3a52
ZJS
300 </refsect1>
301
302 <refsect1>
303 <title>See Also</title>
304 <para>
305 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
306 <citerefentry project='man-pages'><refentrytitle>boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
307 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
308 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
e799056e 309 <citerefentry><refentrytitle>systemd-halt.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
798d3a52
ZJS
310 <citerefentry project='die-net'><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>
311 </para>
312 </refsect1>
013d8a39
LP
313
314</refentry>