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">
6 This file is part of systemd.
8 Copyright 2012 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="bootup">
28 <productname>systemd</productname>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
41 <refentrytitle>bootup</refentrytitle>
42 <manvolnum>7</manvolnum>
46 <refname>bootup</refname>
47 <refpurpose>System bootup process</refpurpose>
51 <title>Description</title>
53 <para>A number of different components are involved in the
54 system boot. Immediately after power-up, the system
55 BIOS will do minimal hardware initialization, and hand
56 control over to a boot loader stored on a persistent
57 storage device. This boot loader will then invoke an
58 OS kernel from disk (or the network). In the Linux
59 case this kernel now (optionally) extracts and
60 executes an initial RAM disk image (initrd) such as
61 <citerefentry><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>
62 which looks for the root file system. After the root
63 file system is found and mounted the initrd hands over
64 control to the system manager (such as
65 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
66 stored on the OS image which is then responsible for
67 probing all remaining hardware, mounting all necessary
68 file systems and spawning all configured
71 <para>On shutdown the system manager stops all
72 services, unmounts all file systems (detaching the
73 storage technologies backing them), and then
74 (optionally) jumps back into the initrd code which
75 unmounts/detaches the root file system and the storage
76 it resides on. As last step the system is powered down.</para>
78 <para>Additional information about the system boot
79 process may be found in
80 <citerefentry><refentrytitle>boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
84 <title>System Manager Bootup</title>
86 <para>At boot, the system manager on the OS image is
87 responsible for initializing the required file
88 systems, services and drivers that are necessary for
89 operation of the system. On
90 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
91 systems this process is split up in various discrete
92 steps which are exposed as target units. (See
93 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>
94 for detailed information about target units.) The
95 boot-up process is highly parallelized so that the
96 order in which specific target units are reached is not
97 deterministic, but still adheres to a limited amount
98 of ordering structure.</para>
100 <para>When systemd starts up the system it will
101 activate all units that are dependencies of
102 <filename>default.target</filename> (as well as
103 recursively all dependencies of these
104 dependencies). Usually
105 <filename>default.target</filename> is simply an alias
106 of <filename>graphical.target</filename> or
107 <filename>multi-user.target</filename> depending on
108 whether the system is configured for a graphical UI or
109 only for a text console. To enforce minimal ordering
110 between the units pulled in a number of well-known
111 target units are available, as listed on
112 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
114 <para>The following chart is a structural overview of
115 these well-known units and their position in the
116 boot-up logic. The arrows describe which units are
117 pulled in and ordered before which other units. Units
118 near the top are started before units nearer to the
119 bottom of the chart.</para>
121 <programlisting>local-fs-pre.target
124 (various mounts and (various swap (various cryptsetup
125 fsck services...) devices...) devices...) (various low-level (various low-level
126 | | | services: udevd, API VFS mounts:
127 v v v tmpfiles, random mqueue, configfs,
128 local-fs.target swap.target cryptsetup.target seed, sysctl, ...) debugfs, ...)
130 \__________________|_________________ | ___________________|____________________/
135 _________________/|\___________________
139 (various | rescue.service
142 v | <emphasis>rescue.target</emphasis>
150 __________________________________/| emergency.service
153 v v v <emphasis>emergency.target</emphasis>
154 display- (various system (various system
155 manager.service services services)
158 | | <emphasis>multi-user.target</emphasis>
160 \_______________ | _________________/
163 <emphasis>graphical.target</emphasis></programlisting>
165 <para>Target units that are commonly used as boot
166 targets are <emphasis>emphasized</emphasis>. These
167 units are good choices as goal targets, for
168 example by passing them to the
169 <varname>systemd.unit=</varname> kernel command line
171 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
172 or by symlinking <filename>default.target</filename>
177 <title>Initrd System Manager Bootup</title>
178 <para>The default target in the initrd is the initrd.target. The bootup process is
179 identical to the System Manager Bootup until it reaches basic.target. From there,
180 systemd approaches the special initrd.target. If the root device can be mounted at
181 /sysroot, the sysroot.mount unit becomes active and the initrd-root-fs.target is
183 The initrd-parse-etc.service scans /sysroot/etc/fstab for a possible /usr mountpoint
184 and additional entries marked with the <emphasis>x-initrd.mount</emphasis> option.
185 All entries found are mounted below /sysroot, and the initrd-fs.target is reached.
186 The initrd-cleanup.service isolates to the initrd-switch-root.target, where cleanup
187 services can run. As the very last step, the initrd-switch-root.service is activated,
188 which will cause the system to switch its root to /sysroot.
192 (identical to System Manager Bootup)
198 ______________________/| |
200 | sysroot.mount <emphasis>emergency.target</emphasis>
203 | initrd-root-fs.target
206 | initrd-parse-etc.service
207 (custom initrd services) |
209 | (sysroot-usr.mount and
210 | various mounts marked
216 \______________________ |
222 initrd-cleanup.service
224 initrd-switch-root.target
227 ______________________/|
229 | initrd-udevadm-cleanup-db.service
231 (custom initrd services) |
233 \______________________ |
236 initrd-switch-root.target
239 initrd-switch-root.service
248 <title>System Manager Shutdown</title>
250 <para>System shutdown also consists of various target
251 units with some minimal ordering structure
257 <programlisting> (conflicts with (conflicts with
258 all system all file system
259 services) mounts, swaps,
264 shutdown.target umount.target
275 _____________________________________/ \_________________________________
279 systemd-reboot.service systemd-poweroff.service systemd-halt.service systemd-kexec.service
282 <emphasis>reboot.target</emphasis> <emphasis>poweroff.target</emphasis> <emphasis>halt.target</emphasis> <emphasis>kexec.target</emphasis></programlisting>
284 <para>Commonly used system shutdown targets are <emphasis>emphasized</emphasis>.</para>
288 <title>See Also</title>
290 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
291 <citerefentry><refentrytitle>boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
292 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
293 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
294 <citerefentry><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>