]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd.swap.xml
man: use same version in public and system ident.
[thirdparty/systemd.git] / man / systemd.swap.xml
CommitLineData
e0cabd4b 1<?xml version='1.0'?> <!--*-nxml-*-->
3a54a157 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
eea10b26 3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
db9ecf05 4<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
e0cabd4b 5
d8e1613e 6<refentry id="systemd.swap" xmlns:xi="http://www.w3.org/2001/XInclude">
798d3a52
ZJS
7 <refentryinfo>
8 <title>systemd.swap</title>
9 <productname>systemd</productname>
798d3a52
ZJS
10 </refentryinfo>
11
12 <refmeta>
13 <refentrytitle>systemd.swap</refentrytitle>
14 <manvolnum>5</manvolnum>
15 </refmeta>
16
17 <refnamediv>
18 <refname>systemd.swap</refname>
19 <refpurpose>Swap unit configuration</refpurpose>
20 </refnamediv>
21
22 <refsynopsisdiv>
23 <para><filename><replaceable>swap</replaceable>.swap</filename></para>
24 </refsynopsisdiv>
25
26 <refsect1>
27 <title>Description</title>
28
29 <para>A unit configuration file whose name ends in
30 <literal>.swap</literal> encodes information about a swap device
31 or file for memory paging controlled and supervised by
32 systemd.</para>
33
34 <para>This man page lists the configuration options specific to
35 this unit type. See
36 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
37 for the common options of all unit configuration files. The common
bdac5608
ZJS
38 configuration items are configured in the generic [Unit] and
39 [Install] sections. The swap specific configuration options are
40 configured in the [Swap] section.</para>
798d3a52
ZJS
41
42 <para>Additional options are listed in
43 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
c129bd5d
LP
44 which define the execution environment the <citerefentry
45 project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry>
3f2d1365 46 program is executed in, in
798d3a52 47 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
c629ff58 48 which define the way these processes are
c129bd5d 49 terminated, and in
798d3a52 50 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
c129bd5d
LP
51 which configure resource control settings for these processes of the
52 unit.</para>
798d3a52 53
f4bf8d2f 54 <para>Swap units must be named after the devices or files they control. Example: the swap device <filename
b0343f8c 55 index="false">/dev/sda5</filename> must be configured in a unit file <filename>dev-sda5.swap</filename>. For
f4bf8d2f
LP
56 details about the escaping logic used to convert a file system path to a unit name, see
57 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Note that swap
58 units cannot be templated, nor is possible to add multiple names to a swap unit by creating additional symlinks to
59 it.</para>
eef34a1d
LP
60
61 <para>Note that swap support on Linux is privileged, swap units are hence only available in the system
62 service manager (and root's user service manager), but not in unprivileged user's service manager.</para>
c129bd5d
LP
63 </refsect1>
64
65 <refsect1>
aed5cb03
ZJS
66 <title>Automatic Dependencies</title>
67
68 <refsect2>
69 <title>Implicit Dependencies</title>
70
71 <para>The following dependencies are implicitly added:</para>
72
73 <itemizedlist>
74 <listitem><para>All swap units automatically get the
75 <varname>BindsTo=</varname> and <varname>After=</varname>
76 dependencies on the device units or the mount units of the files
77 they are activated from.</para></listitem>
78 </itemizedlist>
79
80 <para>Additional implicit dependencies may be added as result of
81 execution and resource control parameters as documented in
82 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
83 and
84 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
85 </refsect2>
86
87 <refsect2>
88 <title>Default Dependencies</title>
89
90 <para>The following dependencies are added unless <varname>DefaultDependencies=no</varname> is set:</para>
91
92 <itemizedlist>
93 <listitem><para>Swap units automatically acquire a <varname>Conflicts=</varname> and a
94 <varname>Before=</varname> dependency on <filename>umount.target</filename> so that they are deactivated at
95 shutdown as well as a <varname>Before=swap.target</varname> dependency.</para></listitem>
96 </itemizedlist>
97 </refsect2>
45f09f93
JL
98 </refsect1>
99
798d3a52
ZJS
100 <refsect1>
101 <title><filename>fstab</filename></title>
102
103 <para>Swap units may either be configured via unit files, or via
104 <filename>/etc/fstab</filename> (see
3ba3a79d 105 <citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>
798d3a52
ZJS
106 for details). Swaps listed in <filename>/etc/fstab</filename> will
107 be converted into native units dynamically at boot and when the
108 configuration of the system manager is reloaded. See
109 <citerefentry><refentrytitle>systemd-fstab-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
110 for details about the conversion.</para>
111
112 <para>If a swap device or file is configured in both
113 <filename>/etc/fstab</filename> and a unit file, the configuration
114 in the latter takes precedence.</para>
115
b938cb90 116 <para>When reading <filename>/etc/fstab</filename>, a few special
798d3a52
ZJS
117 options are understood by systemd which influence how dependencies
118 are created for swap units.</para>
119
120 <variablelist class='fstab-options'>
121 <varlistentry>
122 <term><option>noauto</option></term>
123 <term><option>auto</option></term>
124
b938cb90 125 <listitem><para>With <option>noauto</option>, the swap unit
798d3a52
ZJS
126 will not be added as a dependency for
127 <filename>swap.target</filename>. This means that it will not
128 be activated automatically during boot, unless it is pulled in
a8eaaee7 129 by some other unit. The <option>auto</option> option has the
798d3a52 130 opposite meaning and is the default.</para>
ec07c3c8
AK
131
132 <xi:include href="version-info.xml" xpointer="v218"/>
798d3a52
ZJS
133 </listitem>
134 </varlistentry>
135
136 <varlistentry>
137 <term><option>nofail</option></term>
138
b938cb90 139 <listitem><para>With <option>nofail</option>, the swap unit
798d3a52
ZJS
140 will be only wanted, not required by
141 <filename>swap.target</filename>. This means that the boot
142 will continue even if this swap device is not activated
143 successfully.</para>
aefdc112
AK
144
145 <xi:include href="version-info.xml" xpointer="v218"/>
798d3a52
ZJS
146 </listitem>
147 </varlistentry>
f0c5cda2
ZJS
148
149 <xi:include href="systemd.mount.xml" xpointer="device-timeout" />
150
151 <varlistentry>
152 <term><option>x-systemd.makefs</option></term>
153
154 <listitem><para>The swap structure will be initialized on the device. If the device is not
155 "empty", i.e. it contains any signature, the operation will be skipped. It is hence expected
5238e957 156 that this option remains set even after the device has been initialized.</para>
f0c5cda2
ZJS
157
158 <para>Note that this option can only be used in <filename>/etc/fstab</filename>, and will be
159 ignored when part of the <varname>Options=</varname> setting in a unit file.</para>
160
161 <para>See
162 <citerefentry><refentrytitle>systemd-mkswap@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
163 and the discussion of
164 <citerefentry project='man-pages'><refentrytitle>wipefs</refentrytitle><manvolnum>8</manvolnum></citerefentry>
165 in <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
ec07c3c8
AK
166 </para>
167
168 <xi:include href="version-info.xml" xpointer="v240"/></listitem>
f0c5cda2 169 </varlistentry>
798d3a52
ZJS
170 </variablelist>
171 </refsect1>
172
173 <refsect1>
174 <title>Options</title>
175
d8e1613e
ZJS
176 <para>Swap unit files may include [Unit] and [Install] sections, which are described in
177 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
178 </para>
179
e9dd6984 180 <para>Swap unit files must include a [Swap] section, which carries
798d3a52
ZJS
181 information about the swap device it supervises. A number of
182 options that may be used in this section are shared with other
183 unit types. These options are documented in
184 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
185 and
186 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
187 The options specific to the [Swap] section of swap units are the
188 following:</para>
189
190 <variablelist class='unit-directives'>
191
192 <varlistentry>
193 <term><varname>What=</varname></term>
19d0833b
LP
194 <listitem><para>Takes an absolute path of a device node or file to use for paging. See <citerefentry
195 project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry> for
196 details. If this refers to a device node, a dependency on the respective device unit is automatically
197 created. (See
6dbf4025
ZJS
198 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>
199 for more information.) If this refers to a file, a dependency on the respective mount unit is
200 automatically created. (See
201 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
202 more information.) This option is mandatory. Note that the usual specifier expansion is applied to
203 this setting, literal percent characters should hence be written as
204 <literal class='specifiers'>%%</literal>.</para></listitem>
798d3a52
ZJS
205 </varlistentry>
206
207 <varlistentry>
208 <term><varname>Priority=</varname></term>
209
210 <listitem><para>Swap priority to use when activating the swap
211 device or file. This takes an integer. This setting is
a8eaaee7
JE
212 optional and ignored when the priority is set by <option>pri=</option> in the
213 <varname>Options=</varname> key.</para></listitem>
798d3a52
ZJS
214 </varlistentry>
215
216 <varlistentry>
217 <term><varname>Options=</varname></term>
218
d5cc4be2
LP
219 <listitem><para>May contain an option string for the swap device. This may be used for controlling discard
220 options among other functionality, if the swap backing device supports the discard or trim operation. (See
3ba3a79d 221 <citerefentry project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry>
d5cc4be2 222 for more information.) Note that the usual specifier expansion is applied to this setting, literal percent
ec07c3c8
AK
223 characters should hence be written as <literal>%%</literal>.</para>
224
225 <xi:include href="version-info.xml" xpointer="v217"/></listitem>
798d3a52
ZJS
226 </varlistentry>
227
228 <varlistentry>
229 <term><varname>TimeoutSec=</varname></term>
230 <listitem><para>Configures the time to wait for the swapon
231 command to finish. If a command does not exit within the
232 configured time, the swap will be considered failed and be
233 shut down again. All commands still running will be terminated
234 forcibly via <constant>SIGTERM</constant>, and after another
235 delay of this time with <constant>SIGKILL</constant>. (See
236 <option>KillMode=</option> in
237 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>.)
238 Takes a unit-less value in seconds, or a time span value such
239 as "5min 20s". Pass <literal>0</literal> to disable the
240 timeout logic. Defaults to
241 <varname>DefaultTimeoutStartSec=</varname> from the manager
242 configuration file (see
243 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
244 </para></listitem>
245 </varlistentry>
246 </variablelist>
247
d8e1613e 248 <xi:include href="systemd.service.xml" xpointer="shared-unit-options" />
798d3a52
ZJS
249 </refsect1>
250
251 <refsect1>
252 <title>See Also</title>
13a69c12
DT
253 <para><simplelist type="inline">
254 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
255 <member><citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
256 <member><citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
257 <member><citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
258 <member><citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
259 <member><citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
260 <member><citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
261 <member><citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
262 <member><citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
263 <member><citerefentry project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
264 <member><citerefentry><refentrytitle>systemd-fstab-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
265 <member><citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
266 </simplelist></para>
798d3a52 267 </refsect1>
e0cabd4b
LP
268
269</refentry>