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 v |_________________ | ___________________/
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>
178 <para><filename>timers.target</filename> is pulled-in
179 by <filename>basic.target</filename> asynchronously.
180 This allows timers units to depend on services which
181 become only available later in boot.</para>
185 <title>Bootup in the Initial RAM Disk (initrd)</title>
186 <para>The initial RAM disk implementation (initrd) can
187 be set up using systemd as well. In this case, boot up
188 inside the initrd follows the following
191 <para>The default target in the initrd is
192 <filename>initrd.target</filename>. The bootup process
193 begins identical to the system manager bootup (see
194 above) until it reaches
195 <filename>basic.target</filename>. From there, systemd
196 approaches the special target
197 <filename>initrd.target</filename>. If the root device
198 can be mounted at <filename>/sysroot</filename>, the
199 <filename>sysroot.mount</filename> unit becomes active
200 and <filename>initrd-root-fs.target</filename> is
202 <filename>initrd-parse-etc.service</filename> scans
203 <filename>/sysroot/etc/fstab</filename> for a possible
204 <filename>/usr</filename> mount point and additional
205 entries marked with the
206 <emphasis>x-initrd.mount</emphasis> option. All
207 entries found are mounted below
208 <filename>/sysroot</filename>, and
209 <filename>initrd-fs.target</filename> is reached. The
210 service <filename>initrd-cleanup.service</filename>
212 <filename>initrd-switch-root.target</filename>, where
213 cleanup services can run. As the very last step, the
214 <filename>initrd-switch-root.service</filename> is
215 activated, which will cause the system to switch its
216 root to <filename>/sysroot</filename>.
219 <programlisting> : (beginning identical to above)
224 ______________________/| |
226 | sysroot.mount <emphasis>emergency.target</emphasis>
229 | initrd-root-fs.target
232 v initrd-parse-etc.service
235 | (sysroot-usr.mount and
236 | various mounts marked
242 \______________________ |
248 initrd-cleanup.service
250 initrd-switch-root.target
253 ______________________/|
255 | initrd-udevadm-cleanup-db.service
259 \______________________ |
262 initrd-switch-root.target
265 initrd-switch-root.service
268 Transition to Host OS</programlisting>
273 <title>System Manager Shutdown</title>
275 <para>System shutdown with systemd also consists of
276 various target units with some minimal ordering
277 structure applied:</para>
282 <programlisting> (conflicts with (conflicts with
283 all system all file system
284 services) mounts, swaps,
289 shutdown.target umount.target
300 _____________________________________/ \_________________________________
304 systemd-reboot.service systemd-poweroff.service systemd-halt.service systemd-kexec.service
307 <emphasis>reboot.target</emphasis> <emphasis>poweroff.target</emphasis> <emphasis>halt.target</emphasis> <emphasis>kexec.target</emphasis></programlisting>
309 <para>Commonly used system shutdown targets are <emphasis>emphasized</emphasis>.</para>
313 <title>See Also</title>
315 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
316 <citerefentry project='man-pages'><refentrytitle>boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
317 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
318 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
319 <citerefentry project='die-net'><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>