chiark / gitweb /
man: extend a bit what to expect from the various places apps can store data
[elogind.git] / man / bootup.xml
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">
4
5 <!--
6   This file is part of systemd.
7
8   Copyright 2012 Lennart Poettering
9
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.
14
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.
19
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/>.
22 -->
23
24 <refentry id="bootup">
25
26         <refentryinfo>
27                 <title>bootup</title>
28                 <productname>systemd</productname>
29
30                 <authorgroup>
31                         <author>
32                                 <contrib>Developer</contrib>
33                                 <firstname>Lennart</firstname>
34                                 <surname>Poettering</surname>
35                                 <email>lennart@poettering.net</email>
36                         </author>
37                 </authorgroup>
38         </refentryinfo>
39
40         <refmeta>
41                 <refentrytitle>bootup</refentrytitle>
42                 <manvolnum>7</manvolnum>
43         </refmeta>
44
45         <refnamediv>
46                 <refname>bootup</refname>
47                 <refpurpose>System bootup process</refpurpose>
48         </refnamediv>
49
50         <refsect1>
51                 <title>Description</title>
52
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                 generated by
62                 <citerefentry><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
72                 services.</para>
73
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>
80
81                 <para>Additional information about the system boot
82                 process may be found in
83                 <citerefentry><refentrytitle>boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
84         </refsect1>
85
86         <refsect1>
87                 <title>System Manager Bootup</title>
88
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>
102
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>
116
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>
123
124 <programlisting>local-fs-pre.target
125          |
126          v
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, ...)
132          |                  |                  |                    |                    |
133          \__________________|_________________ | ___________________|____________________/
134                                               \|/
135                                                v
136                                         sysinit.target
137                                                |
138           ____________________________________/|\________________________________________
139          /                  |                  |                    |                    \
140          |                  |                  |                    |                    |
141          v                  v                  |                    v                    v
142      (various           (various               |                (various          rescue.service
143     timers...)          paths...)              |               sockets...)               |
144          |                  |                  |                    |                    v
145          v                  v                  |                    v              <emphasis>rescue.target</emphasis>
146    timers.target      paths.target             |             sockets.target
147          |                  |                  |                    |
148          \__________________|_________________ | ___________________/
149                                               \|/
150                                                v
151                                          basic.target
152                                                |
153           ____________________________________/|                                 emergency.service
154          /                  |                  |                                         |
155          |                  |                  |                                         v
156          v                  v                  v                                 <emphasis>emergency.target</emphasis>
157      display-        (various system    (various system
158  manager.service         services           services)
159          |             required for            |
160          |            graphical UIs)           v
161          |                  |           <emphasis>multi-user.target</emphasis>
162          |                  |                  |
163          \_________________ | _________________/
164                            \|/
165                             v
166                   <emphasis>graphical.target</emphasis></programlisting>
167
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
173                 option (see
174                 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
175                 or by symlinking <filename>default.target</filename>
176                 to them.</para>
177         </refsect1>
178
179         <refsect1>
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
184                 structure.</para>
185
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
196                 reached.  The service
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>
206                 isolates to the
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>.
212                 </para>
213
214 <programlisting>                                               : (beginning identical to above)
215                                                :
216                                                v
217                                          basic.target
218                                                |                                 emergency.service
219                         ______________________/|                                         |
220                        /                       |                                         v
221                        |                  sysroot.mount                          <emphasis>emergency.target</emphasis>
222                        |                       |
223                        |                       v
224                        |             initrd-root-fs.target
225                        |                       |
226                        |                       v
227                        v            initrd-parse-etc.service
228                 (custom initrd                 |
229                  services...)                  v
230                        |            (sysroot-usr.mount and
231                        |             various mounts marked
232                        |               with fstab option
233                        |              x-initrd.mount...)
234                        |                       |
235                        |                       v
236                        |                initrd-fs.target
237                        \______________________ |
238                                               \|
239                                                v
240                                           initrd.target
241                                                |
242                                                v
243                                      initrd-cleanup.service
244                                           isolates to
245                                     initrd-switch-root.target
246                                                |
247                                                v
248                         ______________________/|
249                        /                       v
250                        |        initrd-udevadm-cleanup-db.service
251                        v                       |
252                 (custom initrd                 |
253                  services...)                  |
254                        \______________________ |
255                                               \|
256                                                v
257                                    initrd-switch-root.target
258                                                |
259                                                v
260                                    initrd-switch-root.service
261                                                |
262                                                v
263                                      Transition to Host OS</programlisting>
264         </refsect1>
265
266
267         <refsect1>
268                 <title>System Manager Shutdown</title>
269
270                 <para>System shutdown with systemd also consists of
271                 various target units with some minimal ordering
272                 structure applied:</para>
273
274
275
276
277 <programlisting>                                  (conflicts with  (conflicts with
278                                     all system     all file system
279                                      services)     mounts, swaps,
280                                          |           cryptsetup
281                                          |          devices, ...)
282                                          |                |
283                                          v                v
284                                   shutdown.target    umount.target
285                                          |                |
286                                          \_______   ______/
287                                                  \ /
288                                                   v
289                                          (various low-level
290                                               services)
291                                                   |
292                                                   v
293                                             final.target
294                                                   |
295             _____________________________________/ \_________________________________
296            /                         |                        |                      \
297            |                         |                        |                      |
298            v                         v                        v                      v
299 systemd-reboot.service   systemd-poweroff.service   systemd-halt.service   systemd-kexec.service
300            |                         |                        |                      |
301            v                         v                        v                      v
302     <emphasis>reboot.target</emphasis>             <emphasis>poweroff.target</emphasis>            <emphasis>halt.target</emphasis>           <emphasis>kexec.target</emphasis></programlisting>
303
304                 <para>Commonly used system shutdown targets are <emphasis>emphasized</emphasis>.</para>
305         </refsect1>
306
307         <refsect1>
308                 <title>See Also</title>
309                 <para>
310                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
311                         <citerefentry><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><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry>
315                 </para>
316         </refsect1>
317
318 </refentry>