Debian Codegraph @

upstream/debian-unstable/man7/bootup.7

raw
1 '\" t
2 .TH "BOOTUP" "7" "" "systemd 261~rc3" "bootup"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 bootup \- System bootup process
24 .SH "DESCRIPTION"
25 .PP
26 A number of different components are involved in the boot of a Linux system\&. Immediately after power\-up, the system firmware will do minimal hardware initialization, and hand control over to a boot loader (e\&.g\&.
27 \fBsystemd-boot\fR(7)
28 or
29 \m[blue]\fBGRUB\fR\m[]\&\s-2\u[1]\d\s+2) stored on a persistent storage device\&. This boot loader will then invoke an OS kernel from disk (or the network)\&. On systems using EFI or other types of firmware, this firmware may also load the kernel directly\&.
30 .PP
31 The kernel (optionally) mounts an in\-memory file system, which looks for the root file system\&. Nowadays this is implemented as an "initramfs" \(em a compressed CPIO archive that the kernel extracts into a tmpfs\&. In the past normal file systems using an in\-memory block device (ramdisk) were used, and the name "initrd" is still used to describe both concepts\&. It\*(Aqs the boot loader or the firmware that loads both the kernel and initrd/initramfs images into memory, but the kernel which interprets it as a file system\&.
32 \fBsystemd\fR(1)
33 may be used to manage services in the initrd, similarly to the real system\&.
34 .PP
35 After the root file system is found and mounted, the initrd hands over control to the host\*(Aqs system manager (such as
36 \fBsystemd\fR(1)) stored in the root file system, which is then responsible for probing all remaining hardware, mounting all necessary file systems and spawning all configured services\&.
37 .PP
38 On shutdown, the system manager stops all services, unmounts all non\-busy file systems (detaching the storage technologies backing them), and then (optionally) jumps into the exitrd\&. The exitrd is backed by tmpfs and unmounts/detaches the remaining file systems, including the real root\&. As a last step, the system is powered down\&.
39 .PP
40 Additional information about the system boot process may be found in
41 \fBboot\fR(7)\&.
42 .SH "SYSTEM MANAGER BOOTUP"
43 .PP
44 At boot, the system manager on the OS image is responsible for initializing the required file systems, services and drivers that are necessary for operation of the system\&. On
45 \fBsystemd\fR(1)
46 systems, this process is split up in various discrete steps which are exposed as target units\&. (See
47 \fBsystemd.target\fR(5)
48 for detailed information about target units\&.) The boot\-up process is highly parallelized so that the order in which specific target units are reached is not deterministic, but still adheres to a limited amount of ordering structure\&.
49 .PP
50 When systemd starts up the system, it will activate all units that are dependencies of
51 default\&.target
52 (as well as recursively all dependencies of these dependencies)\&. Usually,
53 default\&.target
54 is simply an alias of
55 graphical\&.target
56 or
57 multi\-user\&.target, depending on whether the system is configured for a graphical UI or only for a text console\&. To enforce minimal ordering between the units pulled in, a number of well\-known target units are available, as listed on
58 \fBsystemd.special\fR(7)\&.
59 .PP
60 The following chart is a structural overview of these well\-known units and their position in the boot\-up logic\&. The arrows describe which units are pulled in and ordered before which other units\&. Units near the top are started before units nearer to the bottom of the chart\&.
61 .sp
62 .if n \{\
63 .RS 4
64 .\}
65 .nf
66 cryptsetup\-pre\&.target veritysetup\-pre\&.target
67 |
68 (various low\-level v
69 API VFS mounts: (various cryptsetup/veritysetup devices\&.\&.\&.)
70 mqueue, configfs, | |
71 debugfs, \&.\&.\&.) v |
72 | cryptsetup\&.target |
73 | (various swap | | remote\-fs\-pre\&.target
74 | devices\&.\&.\&.) | | | |
75 | | | | | v
76 | v local\-fs\-pre\&.target | | | (network file systems)
77 | swap\&.target | | v v |
78 | | v | remote\-cryptsetup\&.target |
79 | | (various low\-level (various mounts and | remote\-veritysetup\&.target |
80 | | services: udevd, fsck services\&.\&.\&.) | | |
81 | | tmpfiles, random | | | remote\-fs\&.target
82 | | seed, sysctl, \&.\&.\&.) v | | |
83 | | | local\-fs\&.target | | _____________/
84 | | | | | |/
85 \e____|______|_______________ ______|___________/ |
86 \e / |
87 v |
88 sysinit\&.target |
89 | |
90 ______________________/|\e_____________________ |
91 / | | | \e |
92 | | | | | |
93 v v | v | |
94 (various (various | (various | |
95 timers\&.\&.\&.) paths\&.\&.\&.) | sockets\&.\&.\&.) | |
96 | | | | | |
97 v v | v | |
98 timers\&.target paths\&.target | sockets\&.target | |
99 | | | | v |
100 v \e_______ | _____/ rescue\&.service |
101 \e|/ | |
102 v v |
103 basic\&.target \fIrescue\&.target\fR |
104 | |
105 ________v____________________ |
106 / | \e |
107 | | | |
108 v v v |
109 display\- (various system (various system |
110 manager\&.service services services) |
111 | required for | |
112 | graphical UIs) v v
113 | | \fImulti\-user\&.target\fR
114 emergency\&.service | | |
115 | \e_____________ | _____________/
116 v \e|/
117 \fIemergency\&.target\fR v
118 \fIgraphical\&.target\fR
119 .fi
120 .if n \{\
121 .RE
122 .\}
123 .PP
124 Target units that are commonly used as boot targets are
125 \fIemphasized\fR\&. These units are good choices as goal targets, for example by passing them to the
126 \fIsystemd\&.unit=\fR
127 kernel command line option (see
128 \fBsystemd\fR(1)) or by symlinking
129 default\&.target
130 to them\&.
131 .PP
132 timers\&.target
133 is pulled\-in by
134 basic\&.target
135 asynchronously\&. This allows timers units to depend on services which become only available later in boot\&.
136 .SH "USER MANAGER STARTUP"
137 .PP
138 The system manager starts the
139 user@\fIuid\fR\&.service
140 unit for each user, which launches a separate unprivileged instance of
141 \fBsystemd\fR
142 for each user \(em the user manager\&. Similarly to the system manager, the user manager starts units which are pulled in by
143 default\&.target\&. The following chart is a structural overview of the well\-known user units\&. For non\-graphical sessions,
144 default\&.target
145 is used\&. Whenever the user logs into a graphical session, the login manager will start the
146 graphical\-session\&.target
147 target that is used to pull in units required for the graphical session\&. A number of targets (shown on the right side) are started when specific hardware is available to the user\&.
148 .sp
149 .if n \{\
150 .RS 4
151 .\}
152 .nf
153 (various (various (various
154 timers\&.\&.\&.) paths\&.\&.\&.) sockets\&.\&.\&.) (sound devices)
155 | | | |
156 v v v v
157 timers\&.target paths\&.target sockets\&.target sound\&.target
158 | | |
159 \e______________ _|_________________/ (bluetooth devices)
160 \e / |
161 V v
162 basic\&.target bluetooth\&.target
163 |
164 __________/ \e_______ (smartcard devices)
165 / \e |
166 | | v
167 | v smartcard\&.target
168 v graphical\-session\-pre\&.target
169 (various user services) | (printers)
170 | v |
171 | (services for the graphical session) v
172 | | printer\&.target
173 v v
174 \fIdefault\&.target\fR graphical\-session\&.target
175 .fi
176 .if n \{\
177 .RE
178 .\}
179 .SH "BOOTUP IN THE INITRD"
180 .PP
181 Systemd can be used in the initrd as well\&. It detects the initrd environment by checking for the
182 /etc/initrd\-release
183 file\&. The default target in the initrd is
184 initrd\&.target\&. The bootup process is identical to the system manager bootup until the target
185 basic\&.target\&. After that, systemd executes the special target
186 initrd\&.target\&. Before any file systems are mounted, the manager will determine whether the system shall resume from hibernation or proceed with normal boot\&. This is accomplished by
187 systemd\-hibernate\-resume\&.service
188 which must be finished before
189 local\-fs\-pre\&.target, so no filesystems can be mounted before the check is complete\&. When the root device becomes available,
190 initrd\-root\-device\&.target
191 is reached\&. If the root device can be mounted at
192 /sysroot, the
193 sysroot\&.mount
194 unit becomes active and
195 initrd\-root\-fs\&.target
196 is reached\&. The service
197 initrd\-parse\-etc\&.service
198 scans
199 /sysroot/etc/fstab
200 for a possible
201 /usr/
202 mount point and additional entries marked with the
203 \fIx\-initrd\&.mount\fR
204 option\&. All entries found are mounted below
205 /sysroot, and
206 initrd\-fs\&.target
207 is reached\&. The service
208 initrd\-cleanup\&.service
209 isolates to the
210 initrd\-switch\-root\&.target, where cleanup services can run\&. As the very last step, the
211 initrd\-switch\-root\&.service
212 is activated, which will cause the system to switch its root to
213 /sysroot\&.
214 .sp
215 .if n \{\
216 .RS 4
217 .\}
218 .nf
219 : (beginning identical to above)
220 :
221 v
222 basic\&.target
223 | emergency\&.service
224 ______________________/| |
225 / | v
226 | initrd\-root\-device\&.target \fIemergency\&.target\fR
227 | |
228 | v
229 | sysroot\&.mount
230 | |
231 | v
232 | initrd\-root\-fs\&.target
233 | |
234 | v
235 v initrd\-parse\-etc\&.service
236 (custom initrd |
237 services\&.\&.\&.) v
238 | (sysroot\-usr\&.mount and
239 | various mounts marked
240 | with fstab option
241 | x\-initrd\&.mount\&.\&.\&.)
242 | |
243 | v
244 | initrd\-fs\&.target
245 \e______________________ |
246 \e|
247 v
248 initrd\&.target
249 |
250 v
251 initrd\-cleanup\&.service
252 isolates to
253 initrd\-switch\-root\&.target
254 |
255 v
256 ______________________/|
257 / v
258 | initrd\-udevadm\-cleanup\-db\&.service
259 v |
260 (custom initrd |
261 services\&.\&.\&.) |
262 \e______________________ |
263 \e|
264 v
265 initrd\-switch\-root\&.target
266 |
267 v
268 initrd\-switch\-root\&.service
269 |
270 v
271 Transition to Host OS
272 .fi
273 .if n \{\
274 .RE
275 .\}
276 .SH "SYSTEM MANAGER SHUTDOWN"
277 .PP
278 System shutdown with systemd also consists of various target units with some minimal ordering structure applied:
279 .sp
280 .if n \{\
281 .RS 4
282 .\}
283 .nf
284 (conflicts with (conflicts with
285 all system all file system
286 services) mounts, swaps,
287 | cryptsetup/
288 | veritysetup
289 | devices, \&.\&.\&.)
290 | |
291 v v
292 shutdown\&.target umount\&.target
293 | |
294 \e_______ ______/
295 \e /
296 v
297 (various low\-level
298 services)
299 |
300 v
301 final\&.target
302 |
303 ___________________________/ \e_________________________________
304 / | | | \e
305 | | | | |
306 v | | | |
307 systemd\-reboot\&.service | | | |
308 | v | | |
309 | systemd\-poweroff\&.service | | |
310 v | v | |
311 \fIreboot\&.target\fR | systemd\-halt\&.service | |
312 v | v |
313 \fIpoweroff\&.target\fR | systemd\-kexec\&.service |
314 v | |
315 \fIhalt\&.target\fR | systemd\-soft\-reboot\&.service
316 v |
317 \fIkexec\&.target\fR |
318 v
319 \fIsoft\-reboot\&.target\fR
320 .fi
321 .if n \{\
322 .RE
323 .\}
324 .PP
325 Commonly used system shutdown targets are
326 \fIemphasized\fR\&.
327 .PP
328 Note that
329 \fBsystemd-halt.service\fR(8),
330 systemd\-reboot\&.service,
331 systemd\-poweroff\&.service
332 and
333 systemd\-kexec\&.service
334 will transition the system and server manager (PID 1) into the second phase of system shutdown (implemented in the
335 systemd\-shutdown
336 binary), which will unmount any remaining file systems, kill any remaining processes and release any other remaining resources, in a simple and robust fashion, without taking any service or unit concept into account anymore\&. At that point, regular applications and resources are generally terminated and released already, the second phase hence operates only as safety net for everything that could not be stopped or released for some reason during the primary, unit\-based shutdown phase described above\&.
337 .SH "THE EXITRD"
338 .PP
339 The "exitrd" is a concept symmetrical to the initrd\&. When the system manager is shutting down and
340 /run/initramfs/shutdown
341 exists, it will switch root to
342 /run/initramfs/
343 and execute
344 /shutdown\&. This program runs from the tmpfs mounted on
345 /run/, so it can unmount the old root file system and perform additional steps, for example dismantle complex storage or perform additional logging about the shutdown\&.
346 .SH "SEE ALSO"
347 .PP
348 \fBsystemd\fR(1), \fBboot\fR(7), \fBsystemd.special\fR(7), \fBsystemd.target\fR(5), \fBsystemd-halt.service\fR(8), \fBsystemd-soft-reboot.service\fR(8)
349 .SH "NOTES"
350 .IP " 1." 4
351 GRUB
352 .RS 4
353 \%https://www.gnu.org/software/grub/
354 .RE