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
54 the system boot. Immediately after power-up, the
55 system BIOS will do minimal hardware initialization,
56 and hand control over to a boot loader stored on a
57 persistent storage device. This boot loader will then
58 invoke an OS kernel from disk (or the network). In the
59 Linux case this kernel (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 (possibly using
63 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
64 for this). After the root file system is found and
65 mounted the initrd hands over control to the host's
66 system manager (such as
67 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
68 stored on the OS image which is then responsible for
69 probing all remaining hardware, mounting all necessary
70 file systems and spawning all configured
73 <para>On shutdown the system manager stops all
74 services, unmounts all file systems (detaching the
75 storage technologies backing them), and then
76 (optionally) jumps back into the initrd code which
77 unmounts/detaches the root file system and the storage
78 it resides on. As last step the system is powered down.</para>
80 <para>Additional information about the system boot
81 process may be found in
82 <citerefentry><refentrytitle>boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
86 <title>System Manager Bootup</title>
88 <para>At boot, the system manager on the OS image is
89 responsible for initializing the required file
90 systems, services and drivers that are necessary for
91 operation of the system. On
92 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
93 systems this process is split up in various discrete
94 steps which are exposed as target units. (See
95 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>
96 for detailed information about target units.) The
97 boot-up process is highly parallelized so that the
98 order in which specific target units are reached is not
99 deterministic, but still adheres to a limited amount
100 of ordering structure.</para>
102 <para>When systemd starts up the system it will
103 activate all units that are dependencies of
104 <filename>default.target</filename> (as well as
105 recursively all dependencies of these
106 dependencies). Usually
107 <filename>default.target</filename> is simply an alias
108 of <filename>graphical.target</filename> or
109 <filename>multi-user.target</filename> depending on
110 whether the system is configured for a graphical UI or
111 only for a text console. To enforce minimal ordering
112 between the units pulled in a number of well-known
113 target units are available, as listed on
114 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
116 <para>The following chart is a structural overview of
117 these well-known units and their position in the
118 boot-up logic. The arrows describe which units are
119 pulled in and ordered before which other units. Units
120 near the top are started before units nearer to the
121 bottom of the chart.</para>
123 <programlisting>local-fs-pre.target
126 (various mounts and (various swap (various cryptsetup
127 fsck services...) devices...) devices...) (various low-level (various low-level
128 | | | services: udevd, API VFS mounts:
129 v v v tmpfiles, random mqueue, configfs,
130 local-fs.target swap.target cryptsetup.target seed, sysctl, ...) debugfs, ...)
132 \__________________|_________________ | ___________________|____________________/
137 ____________________________________/|\________________________________________
141 (various (various | (various rescue.service
142 timers...) paths...) | sockets...) |
144 v v | v <emphasis>rescue.target</emphasis>
145 timers.target paths.target | sockets.target
147 \__________________|_________________ | ___________________/
152 ____________________________________/| emergency.service
155 v v v <emphasis>emergency.target</emphasis>
156 display- (various system (various system
157 manager.service services services)
160 | | <emphasis>multi-user.target</emphasis>
162 \_________________ | _________________/
165 <emphasis>graphical.target</emphasis></programlisting>
167 <para>Target units that are commonly used as boot
168 targets are <emphasis>emphasized</emphasis>. These
169 units are good choices as goal targets, for
170 example by passing them to the
171 <varname>systemd.unit=</varname> kernel command line
173 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
174 or by symlinking <filename>default.target</filename>
179 <title>Bootup in the Initial RAM Disk (initrd)</title>
180 <para>The initial RAM disk implementation (initrd) can
181 be set up using systemd as well. In this case boot up
182 inside the initrd follows the following
185 <para>The default target in the initrd is
186 <filename>initrd.target</filename>. The bootup process
187 begins identical to the system manager bootup (see
188 above) until it reaches
189 <filename>basic.target</filename>. From there, systemd
190 approaches the special target
191 <filename>initrd.target</filename>. If the root device
192 can be mounted at <filename>/sysroot</filename>, the
193 <filename>sysroot.mount</filename> unit becomes active
194 and <filename>initrd-root-fs.target</filename> is
196 <filename>initrd-parse-etc.service</filename> scans
197 <filename>/sysroot/etc/fstab</filename> for a possible
198 <filename>/usr</filename> mount point and additional
199 entries marked with the
200 <emphasis>x-initrd.mount</emphasis> option. All
201 entries found are mounted below
202 <filename>/sysroot</filename>, and
203 <filename>initrd-fs.target</filename> is reached. The
204 service <filename>initrd-cleanup.service</filename>
206 <filename>initrd-switch-root.target</filename>, where
207 cleanup services can run. As the very last step, the
208 <filename>initrd-switch-root.service</filename> is
209 activated, which will cause the system to switch its
210 root to <filename>/sysroot</filename>.
213 <programlisting> : (beginning identical to above)
218 ______________________/| |
220 | sysroot.mount <emphasis>emergency.target</emphasis>
223 | initrd-root-fs.target
226 v initrd-parse-etc.service
229 | (sysroot-usr.mount and
230 | various mounts marked
236 \______________________ |
242 initrd-cleanup.service
244 initrd-switch-root.target
247 ______________________/|
249 | initrd-udevadm-cleanup-db.service
253 \______________________ |
256 initrd-switch-root.target
259 initrd-switch-root.service
262 Transition to Host OS</programlisting>
267 <title>System Manager Shutdown</title>
269 <para>System shutdown with systemd also consists of
270 various target units with some minimal ordering
271 structure applied:</para>
276 <programlisting> (conflicts with (conflicts with
277 all system all file system
278 services) mounts, swaps,
283 shutdown.target umount.target
294 _____________________________________/ \_________________________________
298 systemd-reboot.service systemd-poweroff.service systemd-halt.service systemd-kexec.service
301 <emphasis>reboot.target</emphasis> <emphasis>poweroff.target</emphasis> <emphasis>halt.target</emphasis> <emphasis>kexec.target</emphasis></programlisting>
303 <para>Commonly used system shutdown targets are <emphasis>emphasized</emphasis>.</para>
307 <title>See Also</title>
309 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
310 <citerefentry><refentrytitle>boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
311 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
312 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
313 <citerefentry><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>