1<?xml version='1.0'?> <!--*-nxml-*-->
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6<refentry id="systemd-halt.service">
7
8  <refentryinfo>
9    <title>systemd-halt.service</title>
10    <productname>systemd</productname>
11  </refentryinfo>
12
13  <refmeta>
14    <refentrytitle>systemd-halt.service</refentrytitle>
15    <manvolnum>8</manvolnum>
16  </refmeta>
17
18  <refnamediv>
19    <refname>systemd-halt.service</refname>
20    <refname>systemd-poweroff.service</refname>
21    <refname>systemd-reboot.service</refname>
22    <refname>systemd-kexec.service</refname>
23    <refname>systemd-shutdown</refname>
24    <refpurpose>System shutdown logic</refpurpose>
25  </refnamediv>
26
27  <refsynopsisdiv>
28    <para><filename>systemd-halt.service</filename></para>
29    <para><filename>systemd-poweroff.service</filename></para>
30    <para><filename>systemd-reboot.service</filename></para>
31    <para><filename>systemd-kexec.service</filename></para>
32    <para><filename>/usr/lib/systemd/systemd-shutdown</filename></para>
33    <para><filename>/usr/lib/systemd/system-shutdown/</filename></para>
34  </refsynopsisdiv>
35
36  <refsect1>
37    <title>Description</title>
38
39    <para><filename>systemd-halt.service</filename> is a system
40    service that is pulled in by <filename>halt.target</filename> and
41    is responsible for the actual system halt. Similarly,
42    <filename>systemd-poweroff.service</filename> is pulled in by
43    <filename>poweroff.target</filename>,
44    <filename>systemd-reboot.service</filename> by
45    <filename>reboot.target</filename> and
46    <filename>systemd-kexec.service</filename> by
47    <filename>kexec.target</filename> to execute the respective
48    actions.</para>
49
50    <para>When these services are run, they ensure that PID 1 is
51    replaced by the
52    <filename>/usr/lib/systemd/systemd-shutdown</filename> tool which
53    is then responsible for the actual shutdown. Before shutting down,
54    this binary will try to unmount all remaining file systems,
55    disable all remaining swap devices, detach all remaining storage
56    devices and kill all remaining processes.</para>
57
58    <para>It is necessary to have this code in a separate binary
59    because otherwise rebooting after an upgrade might be broken — the
60    running PID 1 could still depend on libraries which are not
61    available any more, thus keeping the file system busy, which then
62    cannot be re-mounted read-only.</para>
63
64    <para>Immediately before executing the actual system
65    halt/poweroff/reboot/kexec <filename>systemd-shutdown</filename>
66    will run all executables in
67    <filename>/usr/lib/systemd/system-shutdown/</filename> and pass
68    one arguments to them: either <literal>halt</literal>,
69    <literal>poweroff</literal>, <literal>reboot</literal> or
70    <literal>kexec</literal>, depending on the chosen action. All
71    executables in this directory are executed in parallel, and
72    execution of the action is not continued before all executables
73    finished.</para>
74
75    <para>Note that <filename>systemd-halt.service</filename> (and the
76    related units) should never be executed directly. Instead, trigger
77    system shutdown with a command such as <literal>systemctl
78    halt</literal> or suchlike.</para>
79  </refsect1>
80
81  <refsect1>
82    <title>See Also</title>
83    <para>
84      <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
85      <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
86      <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
87      <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
88      <citerefentry><refentrytitle>systemd-suspend.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
89      <citerefentry><refentrytitle>bootup</refentrytitle><manvolnum>7</manvolnum></citerefentry>
90    </para>
91  </refsect1>
92
93</refentry>
94