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