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