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 <!ENTITY % entities SYSTEM
"custom-entities.ent" >
9 This file is part of systemd.
11 Copyright 2010 Lennart Poettering
13 systemd is free software; you can redistribute it and/or modify it
14 under the terms of the GNU Lesser General Public License as published by
15 the Free Software Foundation; either version 2.1 of the License, or
16 (at your option) any later version.
18 systemd is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
23 You should have received a copy of the GNU Lesser General Public License
24 along with systemd; If not, see <http://www.gnu.org/licenses/>.
27 <refentry id=
"systemd.swap">
29 <title>systemd.swap
</title>
30 <productname>systemd
</productname>
34 <contrib>Developer
</contrib>
35 <firstname>Lennart
</firstname>
36 <surname>Poettering
</surname>
37 <email>lennart@poettering.net
</email>
43 <refentrytitle>systemd.swap
</refentrytitle>
44 <manvolnum>5</manvolnum>
48 <refname>systemd.swap
</refname>
49 <refpurpose>Swap unit configuration
</refpurpose>
53 <para><filename><replaceable>swap
</replaceable>.swap
</filename></para>
57 <title>Description
</title>
59 <para>A unit configuration file whose name ends in
60 <literal>.swap
</literal> encodes information about a swap device
61 or file for memory paging controlled and supervised by
64 <para>This man page lists the configuration options specific to
66 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
67 for the common options of all unit configuration files. The common
68 configuration items are configured in the generic [Unit] and
69 [Install] sections. The swap specific configuration options are
70 configured in the [Swap] section.
</para>
72 <para>Additional options are listed in
73 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
74 which define the execution environment the
75 <citerefentry project='man-pages'
><refentrytitle>swapon
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
76 binary is executed in, and in
77 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
78 which define the way the processes are terminated, and in
79 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
80 which configure resource control settings for the processes of the
83 <para>Swap units must be named after the devices
84 or files they control. Example: the swap device
85 <filename noindex='true'
>/dev/sda5
</filename> must be configured in a
86 unit file
<filename>dev-sda5.swap
</filename>. For details about
87 the escaping logic used to convert a file system path to a unit
89 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
</para>
91 <para>All swap units automatically get the appropriate
92 dependencies on the devices or on the mount points of the files
93 they are activated from.
</para>
95 <para>Swap units with
<varname>DefaultDependencies=
</varname>
96 enabled implicitly acquire a conflicting dependency to
97 <filename>umount.target
</filename> so that they are deactivated at
102 <title><filename>fstab
</filename></title>
104 <para>Swap units may either be configured via unit files, or via
105 <filename>/etc/fstab
</filename> (see
106 <citerefentry project='man-pages'
><refentrytitle>fstab
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
107 for details). Swaps listed in
<filename>/etc/fstab
</filename> will
108 be converted into native units dynamically at boot and when the
109 configuration of the system manager is reloaded. See
110 <citerefentry><refentrytitle>systemd-fstab-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
111 for details about the conversion.
</para>
113 <para>If a swap device or file is configured in both
114 <filename>/etc/fstab
</filename> and a unit file, the configuration
115 in the latter takes precedence.
</para>
117 <para>When reading
<filename>/etc/fstab
</filename> a few special
118 options are understood by systemd which influence how dependencies
119 are created for swap units.
</para>
121 <variablelist class='fstab-options'
>
123 <term><option>noauto
</option></term>
124 <term><option>auto
</option></term>
126 <listitem><para>With
<option>noauto
</option> the swap unit
127 will not be added as a dependency for
128 <filename>swap.target
</filename>. This means that it will not
129 be activated automatically during boot, unless it is pulled in
130 by some other unit. Option
<option>auto
</option> has the
131 opposite meaning and is the default.
</para>
136 <term><option>nofail
</option></term>
138 <listitem><para>With
<option>nofail
</option> the swap unit
139 will be only wanted, not required by
140 <filename>swap.target
</filename>. This means that the boot
141 will continue even if this swap device is not activated
149 <title>Options
</title>
151 <para>Swap files must include a [Swap] section, which carries
152 information about the swap device it supervises. A number of
153 options that may be used in this section are shared with other
154 unit types. These options are documented in
155 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
157 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
158 The options specific to the [Swap] section of swap units are the
161 <variablelist class='unit-directives'
>
164 <term><varname>What=
</varname></term>
165 <listitem><para>Takes an absolute path of a device node or
166 file to use for paging. See
167 <citerefentry project='man-pages'
><refentrytitle>swapon
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
168 for details. If this refers to a device node, a dependency on
169 the respective device unit is automatically created. (See
170 <citerefentry><refentrytitle>systemd.device
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
171 for more information.) If this refers to a file, a dependency
172 on the respective mount unit is automatically created. (See
173 <citerefentry><refentrytitle>systemd.mount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
174 for more information.) This option is
175 mandatory.
</para></listitem>
179 <term><varname>Priority=
</varname></term>
181 <listitem><para>Swap priority to use when activating the swap
182 device or file. This takes an integer. This setting is
183 optional and ignored when priority is set by
<option>pri=
</option> in the
184 <varname>Options=
</varname> option.
</para></listitem>
188 <term><varname>Options=
</varname></term>
190 <listitem><para>May contain an option string for the swap
191 device. This may be used for controlling discard options among
192 other functionality, if the swap backing device supports the
193 discard or trim operation. (See
194 <citerefentry project='man-pages'
><refentrytitle>swapon
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
195 for more information.)
</para></listitem>
199 <term><varname>TimeoutSec=
</varname></term>
200 <listitem><para>Configures the time to wait for the swapon
201 command to finish. If a command does not exit within the
202 configured time, the swap will be considered failed and be
203 shut down again. All commands still running will be terminated
204 forcibly via
<constant>SIGTERM
</constant>, and after another
205 delay of this time with
<constant>SIGKILL
</constant>. (See
206 <option>KillMode=
</option> in
207 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.)
208 Takes a unit-less value in seconds, or a time span value such
209 as
"5min 20s". Pass
<literal>0</literal> to disable the
210 timeout logic. Defaults to
211 <varname>DefaultTimeoutStartSec=
</varname> from the manager
212 configuration file (see
213 <citerefentry><refentrytitle>systemd-system.conf
</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
219 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
221 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
222 for more settings.
</para>
226 <title>See Also
</title>
228 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
229 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
230 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
231 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
232 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
233 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
234 <citerefentry><refentrytitle>systemd.device
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
235 <citerefentry><refentrytitle>systemd.mount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
236 <citerefentry project='man-pages'
><refentrytitle>swapon
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
237 <citerefentry><refentrytitle>systemd-fstab-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
238 <citerefentry><refentrytitle>systemd.directives
</refentrytitle><manvolnum>7</manvolnum></citerefentry>