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