]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.swap.xml
acedb9fb25e961d6e9bb7d9badbe8e8390f82442
[thirdparty/systemd.git] / man / systemd.swap.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 SPDX-License-Identifier: LGPL-2.1+
7
8 This file is part of systemd.
9
10 Copyright 2010 Lennart Poettering
11
12 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
16
17 systemd is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 -->
25
26 <refentry id="systemd.swap">
27 <refentryinfo>
28 <title>systemd.swap</title>
29 <productname>systemd</productname>
30
31 <authorgroup>
32 <author>
33 <contrib>Developer</contrib>
34 <firstname>Lennart</firstname>
35 <surname>Poettering</surname>
36 <email>lennart@poettering.net</email>
37 </author>
38 </authorgroup>
39 </refentryinfo>
40
41 <refmeta>
42 <refentrytitle>systemd.swap</refentrytitle>
43 <manvolnum>5</manvolnum>
44 </refmeta>
45
46 <refnamediv>
47 <refname>systemd.swap</refname>
48 <refpurpose>Swap unit configuration</refpurpose>
49 </refnamediv>
50
51 <refsynopsisdiv>
52 <para><filename><replaceable>swap</replaceable>.swap</filename></para>
53 </refsynopsisdiv>
54
55 <refsect1>
56 <title>Description</title>
57
58 <para>A unit configuration file whose name ends in
59 <literal>.swap</literal> encodes information about a swap device
60 or file for memory paging controlled and supervised by
61 systemd.</para>
62
63 <para>This man page lists the configuration options specific to
64 this unit type. See
65 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
66 for the common options of all unit configuration files. The common
67 configuration items are configured in the generic [Unit] and
68 [Install] sections. The swap specific configuration options are
69 configured in the [Swap] section.</para>
70
71 <para>Additional options are listed in
72 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
73 which define the execution environment the <citerefentry
74 project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry>
75 program is executed in, in
76 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
77 which define the way these processes are
78 terminated, and in
79 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
80 which configure resource control settings for these processes of the
81 unit.</para>
82
83 <para>Swap units must be named after the devices or files they control. Example: the swap device <filename
84 noindex='true'>/dev/sda5</filename> must be configured in a unit file <filename>dev-sda5.swap</filename>. For
85 details about the escaping logic used to convert a file system path to a unit name, see
86 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Note that swap
87 units cannot be templated, nor is possible to add multiple names to a swap unit by creating additional symlinks to
88 it.</para>
89 </refsect1>
90
91 <refsect1>
92 <title>Implicit Dependencies</title>
93
94 <para>The following dependencies are implicitly added:</para>
95
96 <itemizedlist>
97 <listitem><para>All swap units automatically get the
98 <varname>BindsTo=</varname> and <varname>After=</varname>
99 dependencies on the device units or the mount units of the files
100 they are activated from.</para></listitem>
101 </itemizedlist>
102
103 <para>Additional implicit dependencies may be added as result of
104 execution and resource control parameters as documented in
105 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
106 and
107 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
108 </refsect1>
109
110 <refsect1>
111 <title>Default Dependencies</title>
112
113 <para>The following dependencies are added unless <varname>DefaultDependencies=no</varname> is set:</para>
114
115 <itemizedlist>
116 <listitem><para>Swap units automatically acquire a <varname>Conflicts=</varname> and a
117 <varname>Before=</varname> dependency on <filename>umount.target</filename> so that they are deactivated at
118 shutdown as well as a <varname>Before=swap.target</varname> dependency.</para></listitem>
119 </itemizedlist>
120 </refsect1>
121
122 <refsect1>
123 <title><filename>fstab</filename></title>
124
125 <para>Swap units may either be configured via unit files, or via
126 <filename>/etc/fstab</filename> (see
127 <citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>
128 for details). Swaps listed in <filename>/etc/fstab</filename> will
129 be converted into native units dynamically at boot and when the
130 configuration of the system manager is reloaded. See
131 <citerefentry><refentrytitle>systemd-fstab-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
132 for details about the conversion.</para>
133
134 <para>If a swap device or file is configured in both
135 <filename>/etc/fstab</filename> and a unit file, the configuration
136 in the latter takes precedence.</para>
137
138 <para>When reading <filename>/etc/fstab</filename>, a few special
139 options are understood by systemd which influence how dependencies
140 are created for swap units.</para>
141
142 <variablelist class='fstab-options'>
143 <varlistentry>
144 <term><option>noauto</option></term>
145 <term><option>auto</option></term>
146
147 <listitem><para>With <option>noauto</option>, the swap unit
148 will not be added as a dependency for
149 <filename>swap.target</filename>. This means that it will not
150 be activated automatically during boot, unless it is pulled in
151 by some other unit. The <option>auto</option> option has the
152 opposite meaning and is the default.</para>
153 </listitem>
154 </varlistentry>
155
156 <varlistentry>
157 <term><option>nofail</option></term>
158
159 <listitem><para>With <option>nofail</option>, the swap unit
160 will be only wanted, not required by
161 <filename>swap.target</filename>. This means that the boot
162 will continue even if this swap device is not activated
163 successfully.</para>
164 </listitem>
165 </varlistentry>
166 </variablelist>
167 </refsect1>
168
169 <refsect1>
170 <title>Options</title>
171
172 <para>Swap files must include a [Swap] section, which carries
173 information about the swap device it supervises. A number of
174 options that may be used in this section are shared with other
175 unit types. These options are documented in
176 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
177 and
178 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
179 The options specific to the [Swap] section of swap units are the
180 following:</para>
181
182 <variablelist class='unit-directives'>
183
184 <varlistentry>
185 <term><varname>What=</varname></term>
186 <listitem><para>Takes an absolute path of a device node or file to use for paging. See <citerefentry
187 project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry> for
188 details. If this refers to a device node, a dependency on the respective device unit is automatically
189 created. (See
190 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more
191 information.) If this refers to a file, a dependency on the respective mount unit is automatically
192 created. (See <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
193 for more information.) This option is mandatory. Note that the usual specifier expansion is applied to this
194 setting, literal percent characters should hence be written as <literal>%%</literal>.</para></listitem>
195 </varlistentry>
196
197 <varlistentry>
198 <term><varname>Priority=</varname></term>
199
200 <listitem><para>Swap priority to use when activating the swap
201 device or file. This takes an integer. This setting is
202 optional and ignored when the priority is set by <option>pri=</option> in the
203 <varname>Options=</varname> key.</para></listitem>
204 </varlistentry>
205
206 <varlistentry>
207 <term><varname>Options=</varname></term>
208
209 <listitem><para>May contain an option string for the swap device. This may be used for controlling discard
210 options among other functionality, if the swap backing device supports the discard or trim operation. (See
211 <citerefentry project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry>
212 for more information.) Note that the usual specifier expansion is applied to this setting, literal percent
213 characters should hence be written as <literal>%%</literal>.</para></listitem>
214 </varlistentry>
215
216 <varlistentry>
217 <term><varname>TimeoutSec=</varname></term>
218 <listitem><para>Configures the time to wait for the swapon
219 command to finish. If a command does not exit within the
220 configured time, the swap will be considered failed and be
221 shut down again. All commands still running will be terminated
222 forcibly via <constant>SIGTERM</constant>, and after another
223 delay of this time with <constant>SIGKILL</constant>. (See
224 <option>KillMode=</option> in
225 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>.)
226 Takes a unit-less value in seconds, or a time span value such
227 as "5min 20s". Pass <literal>0</literal> to disable the
228 timeout logic. Defaults to
229 <varname>DefaultTimeoutStartSec=</varname> from the manager
230 configuration file (see
231 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
232 </para></listitem>
233 </varlistentry>
234 </variablelist>
235
236 <para>Check
237 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
238 and
239 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>
240 for more settings.</para>
241 </refsect1>
242
243 <refsect1>
244 <title>See Also</title>
245 <para>
246 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
247 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
248 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
249 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
250 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
251 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
252 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
253 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
254 <citerefentry project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
255 <citerefentry><refentrytitle>systemd-fstab-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
256 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>
257 </para>
258 </refsect1>
259
260 </refentry>