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
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
66 mounted, the initrd hands over control to the host's
67 system manager (such as
68 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
69 stored on the OS image, which is then responsible for
70 probing all remaining hardware, mounting all necessary
71 file systems and spawning all configured
74 <para>On shutdown, the system manager stops all
75 services, unmounts all file systems (detaching the
76 storage technologies backing them), and then
77 (optionally) jumps back into the initrd code which
78 unmounts/detaches the root file system and the storage
79 it resides on. As a last step, the system is powered down.</para>
81 <para>Additional information about the system boot
82 process may be found in
83 <citerefentry project='man-pages'><refentrytitle>boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
87 <title>System Manager Bootup</title>
89 <para>At boot, the system manager on the OS image is
90 responsible for initializing the required file
91 systems, services and drivers that are necessary for
92 operation of the system. On
93 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
94 systems, this process is split up in various discrete
95 steps which are exposed as target units. (See
96 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>
97 for detailed information about target units.) The
98 boot-up process is highly parallelized so that the
99 order in which specific target units are reached is not
100 deterministic, but still adheres to a limited amount
101 of ordering structure.</para>
103 <para>When systemd starts up the system, it will
104 activate all units that are dependencies of
105 <filename>default.target</filename> (as well as
106 recursively all dependencies of these
107 dependencies). Usually,
108 <filename>default.target</filename> is simply an alias
109 of <filename>graphical.target</filename> or
110 <filename>multi-user.target</filename>, depending on
111 whether the system is configured for a graphical UI or
112 only for a text console. To enforce minimal ordering
113 between the units pulled in, a number of well-known
114 target units are available, as listed on
115 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
117 <para>The following chart is a structural overview of
118 these well-known units and their position in the
119 boot-up logic. The arrows describe which units are
120 pulled in and ordered before which other units. Units
121 near the top are started before units nearer to the
122 bottom of the chart.</para>
124 <programlisting>local-fs-pre.target
127 (various mounts and (various swap (various cryptsetup
128 fsck services...) devices...) devices...) (various low-level (various low-level
129 | | | services: udevd, API VFS mounts:
130 v v v tmpfiles, random mqueue, configfs,
131 local-fs.target swap.target cryptsetup.target seed, sysctl, ...) debugfs, ...)
133 \__________________|_________________ | ___________________|____________________/
138 ____________________________________/|\________________________________________
142 (various (various | (various rescue.service
143 timers...) paths...) | sockets...) |
145 v v | v <emphasis>rescue.target</emphasis>
146 timers.target paths.target | sockets.target
148 \__________________|_________________ | ___________________/
153 ____________________________________/| emergency.service
156 v v v <emphasis>emergency.target</emphasis>
157 display- (various system (various system
158 manager.service services services)
161 | | <emphasis>multi-user.target</emphasis>
163 \_________________ | _________________/
166 <emphasis>graphical.target</emphasis></programlisting>
168 <para>Target units that are commonly used as boot
169 targets are <emphasis>emphasized</emphasis>. These
170 units are good choices as goal targets, for
171 example by passing them to the
172 <varname>systemd.unit=</varname> kernel command line
174 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
175 or by symlinking <filename>default.target</filename>
180 <title>Bootup in the Initial RAM Disk (initrd)</title>
181 <para>The initial RAM disk implementation (initrd) can
182 be set up using systemd as well. In this case, boot up
183 inside the initrd follows the following
186 <para>The default target in the initrd is
187 <filename>initrd.target</filename>. The bootup process
188 begins identical to the system manager bootup (see
189 above) until it reaches
190 <filename>basic.target</filename>. From there, systemd
191 approaches the special target
192 <filename>initrd.target</filename>. If the root device
193 can be mounted at <filename>/sysroot</filename>, the
194 <filename>sysroot.mount</filename> unit becomes active
195 and <filename>initrd-root-fs.target</filename> is
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
200 entries marked with the
201 <emphasis>x-initrd.mount</emphasis> option. All
202 entries found are mounted below
203 <filename>/sysroot</filename>, and
204 <filename>initrd-fs.target</filename> is reached. The
205 service <filename>initrd-cleanup.service</filename>
207 <filename>initrd-switch-root.target</filename>, where
208 cleanup services can run. As the very last step, the
209 <filename>initrd-switch-root.service</filename> is
210 activated, which will cause the system to switch its
211 root to <filename>/sysroot</filename>.
214 <programlisting> : (beginning identical to above)
219 ______________________/| |
221 | sysroot.mount <emphasis>emergency.target</emphasis>
224 | initrd-root-fs.target
227 v initrd-parse-etc.service
230 | (sysroot-usr.mount and
231 | various mounts marked
237 \______________________ |
243 initrd-cleanup.service
245 initrd-switch-root.target
248 ______________________/|
250 | initrd-udevadm-cleanup-db.service
254 \______________________ |
257 initrd-switch-root.target
260 initrd-switch-root.service
263 Transition to Host OS</programlisting>
268 <title>System Manager Shutdown</title>
270 <para>System shutdown with systemd also consists of
271 various target units with some minimal ordering
272 structure applied:</para>
277 <programlisting> (conflicts with (conflicts with
278 all system all file system
279 services) mounts, swaps,
284 shutdown.target umount.target
295 _____________________________________/ \_________________________________
299 systemd-reboot.service systemd-poweroff.service systemd-halt.service systemd-kexec.service
302 <emphasis>reboot.target</emphasis> <emphasis>poweroff.target</emphasis> <emphasis>halt.target</emphasis> <emphasis>kexec.target</emphasis></programlisting>
304 <para>Commonly used system shutdown targets are <emphasis>emphasized</emphasis>.</para>
308 <title>See Also</title>
310 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
311 <citerefentry project='man-pages'><refentrytitle>boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
312 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
313 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
314 <citerefentry project='die-net'><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>