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 2010 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=
"systemd.swap">
26 <title>systemd.swap
</title>
27 <productname>systemd
</productname>
31 <contrib>Developer
</contrib>
32 <firstname>Lennart
</firstname>
33 <surname>Poettering
</surname>
34 <email>lennart@poettering.net
</email>
40 <refentrytitle>systemd.swap
</refentrytitle>
41 <manvolnum>5</manvolnum>
45 <refname>systemd.swap
</refname>
46 <refpurpose>Swap unit configuration
</refpurpose>
50 <para><filename><replaceable>swap
</replaceable>.swap
</filename></para>
54 <title>Description
</title>
56 <para>A unit configuration file whose name ends in
57 <literal>.swap
</literal> encodes information about a swap device
58 or file for memory paging controlled and supervised by
61 <para>This man page lists the configuration options specific to
63 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
64 for the common options of all unit configuration files. The common
65 configuration items are configured in the generic [Unit] and
66 [Install] sections. The swap specific configuration options are
67 configured in the [Swap] section.
</para>
69 <para>Additional options are listed in
70 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
71 which define the execution environment the
<citerefentry
72 project='man-pages'
><refentrytitle>swapon
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
73 binary is executed in, in
74 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
75 which define the way these processes are
77 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
78 which configure resource control settings for these processes of the
81 <para>Swap units must be named after the devices or files they control. Example: the swap device
<filename
82 noindex='true'
>/dev/sda5
</filename> must be configured in a unit file
<filename>dev-sda5.swap
</filename>. For
83 details about the escaping logic used to convert a file system path to a unit name, see
84 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Note that swap
85 units cannot be templated, nor is possible to add multiple names to a swap unit by creating additional symlinks to
90 <title>Implicit Dependencies
</title>
92 <para>The following dependencies are implicitly added:
</para>
95 <listitem><para>All swap units automatically get the
96 <varname>BindsTo=
</varname> and
<varname>After=
</varname>
97 dependencies on the device units or the mount units of the files
98 they are activated from.
</para></listitem>
101 <para>Additional implicit dependencies may be added as result of
102 execution and resource control parameters as documented in
103 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
105 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
</para>
109 <title>Default Dependencies
</title>
111 <para>The following dependencies are added unless
<varname>DefaultDependencies=no
</varname> is set:
</para>
114 <listitem><para>Swap units automatically acquire a
<varname>Conflicts=
</varname> and a
115 <varname>Before=
</varname> dependency on
<filename>umount.target
</filename> so that they are deactivated at
116 shutdown as well as a
<varname>Before=swap.target
</varname> dependency.
</para></listitem>
121 <title><filename>fstab
</filename></title>
123 <para>Swap units may either be configured via unit files, or via
124 <filename>/etc/fstab
</filename> (see
125 <citerefentry project='man-pages'
><refentrytitle>fstab
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
126 for details). Swaps listed in
<filename>/etc/fstab
</filename> will
127 be converted into native units dynamically at boot and when the
128 configuration of the system manager is reloaded. See
129 <citerefentry><refentrytitle>systemd-fstab-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
130 for details about the conversion.
</para>
132 <para>If a swap device or file is configured in both
133 <filename>/etc/fstab
</filename> and a unit file, the configuration
134 in the latter takes precedence.
</para>
136 <para>When reading
<filename>/etc/fstab
</filename>, a few special
137 options are understood by systemd which influence how dependencies
138 are created for swap units.
</para>
140 <variablelist class='fstab-options'
>
142 <term><option>noauto
</option></term>
143 <term><option>auto
</option></term>
145 <listitem><para>With
<option>noauto
</option>, the swap unit
146 will not be added as a dependency for
147 <filename>swap.target
</filename>. This means that it will not
148 be activated automatically during boot, unless it is pulled in
149 by some other unit. The
<option>auto
</option> option has the
150 opposite meaning and is the default.
</para>
155 <term><option>nofail
</option></term>
157 <listitem><para>With
<option>nofail
</option>, the swap unit
158 will be only wanted, not required by
159 <filename>swap.target
</filename>. This means that the boot
160 will continue even if this swap device is not activated
168 <title>Options
</title>
170 <para>Swap files must include a [Swap] section, which carries
171 information about the swap device it supervises. A number of
172 options that may be used in this section are shared with other
173 unit types. These options are documented in
174 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
176 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
177 The options specific to the [Swap] section of swap units are the
180 <variablelist class='unit-directives'
>
183 <term><varname>What=
</varname></term>
184 <listitem><para>Takes an absolute path of a device node or file to use for paging. See
<citerefentry
185 project='man-pages'
><refentrytitle>swapon
</refentrytitle><manvolnum>8</manvolnum></citerefentry> for
186 details. If this refers to a device node, a dependency on the respective device unit is automatically
188 <citerefentry><refentrytitle>systemd.device
</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more
189 information.) If this refers to a file, a dependency on the respective mount unit is automatically
190 created. (See
<citerefentry><refentrytitle>systemd.mount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
191 for more information.) This option is mandatory. Note that the usual specifier expansion is applied to this
192 setting, literal percent characters should hence be written as
<literal>%%
</literal>.
</para></listitem>
196 <term><varname>Priority=
</varname></term>
198 <listitem><para>Swap priority to use when activating the swap
199 device or file. This takes an integer. This setting is
200 optional and ignored when the priority is set by
<option>pri=
</option> in the
201 <varname>Options=
</varname> key.
</para></listitem>
205 <term><varname>Options=
</varname></term>
207 <listitem><para>May contain an option string for the swap device. This may be used for controlling discard
208 options among other functionality, if the swap backing device supports the discard or trim operation. (See
209 <citerefentry project='man-pages'
><refentrytitle>swapon
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
210 for more information.) Note that the usual specifier expansion is applied to this setting, literal percent
211 characters should hence be written as
<literal>%%
</literal>.
</para></listitem>
215 <term><varname>TimeoutSec=
</varname></term>
216 <listitem><para>Configures the time to wait for the swapon
217 command to finish. If a command does not exit within the
218 configured time, the swap will be considered failed and be
219 shut down again. All commands still running will be terminated
220 forcibly via
<constant>SIGTERM
</constant>, and after another
221 delay of this time with
<constant>SIGKILL
</constant>. (See
222 <option>KillMode=
</option> in
223 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.)
224 Takes a unit-less value in seconds, or a time span value such
225 as
"5min 20s". Pass
<literal>0</literal> to disable the
226 timeout logic. Defaults to
227 <varname>DefaultTimeoutStartSec=
</varname> from the manager
228 configuration file (see
229 <citerefentry><refentrytitle>systemd-system.conf
</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
235 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
237 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
238 for more settings.
</para>
242 <title>See Also
</title>
244 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
245 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
246 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
247 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
248 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
249 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
250 <citerefentry><refentrytitle>systemd.device
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
251 <citerefentry><refentrytitle>systemd.mount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
252 <citerefentry project='man-pages'
><refentrytitle>swapon
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
253 <citerefentry><refentrytitle>systemd-fstab-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
254 <citerefentry><refentrytitle>systemd.directives
</refentrytitle><manvolnum>7</manvolnum></citerefentry>