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>Systemd in the Initrd</title>
178 <para>If the initrd creation tool used the services provided
179 by systemd, the default target in the initrd is the
180 initrd-fs.target. The process is the same as above until the basic.target is reached.
181 Systemd now continues to the initrd.target. If the root device could be mounted
182 on /sysroot, the sysroot.mount unit is active and the initrd-root-fs.target is reached.
183 initrd-parse-etc.service scans /sysroot/etc/fstab for the /usr mountpoint and for entries
184 marked with the <emphasis>x-initrd.mount</emphasis> option set. If these mountpoint are
185 mounted in /sysroot, the initrd-fs.target is reached.
186 The initrd-cleanup.service isolates to the initrd-switch-root.target,
187 where cleanup services can run. At the very last end
188 initrd-switch-root.service is activated, which will cause
189 the system to switch root to /sysroot.
199 ______________________/| |
201 | sysroot.mount <emphasis>emergency.target</emphasis>
204 | initrd-root-fs.target
207 | initrd-parse-etc.service
208 (custom initrd services) |
210 | (sysroot-usr.mount and
211 | various mounts marked
218 \______________________ |
224 initrd-cleanup.service
226 initrd-switch-root.target
229 ______________________/|
231 | initrd-udevadm-cleanup-db.service
233 (custom initrd services) |
235 \______________________ |
238 initrd-switch-root.target
241 initrd-switch-root.service
250 <title>System Manager Shutdown</title>
252 <para>System shutdown also consists of various target
253 units with some minimal ordering structure
259 <programlisting> (conflicts with (conflicts with
260 all system all file system
261 services) mounts, swaps,
266 shutdown.target umount.target
277 _____________________________________/ \_________________________________
281 systemd-reboot.service systemd-poweroff.service systemd-halt.service systemd-kexec.service
284 <emphasis>reboot.target</emphasis> <emphasis>poweroff.target</emphasis> <emphasis>halt.target</emphasis> <emphasis>kexec.target</emphasis></programlisting>
286 <para>Commonly used system shutdown targets are <emphasis>emphasized</emphasis>.</para>
290 <title>See Also</title>
292 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
293 <citerefentry><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>,
296 <citerefentry><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>