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