]>
Commit | Line | Data |
---|---|---|
e0cabd4b | 1 | <?xml version='1.0'?> <!--*-nxml-*--> |
e0cabd4b | 2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" |
12b42c76 | 3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> |
e0cabd4b LP |
4 | |
5 | <!-- | |
572eb058 | 6 | SPDX-License-Identifier: LGPL-2.1+ |
e0cabd4b LP |
7 | --> |
8 | ||
f0c5cda2 ZJS |
9 | <refentry id="systemd.swap" |
10 | xmlns:xi="http://www.w3.org/2001/XInclude"> | |
11 | ||
798d3a52 ZJS |
12 | <refentryinfo> |
13 | <title>systemd.swap</title> | |
14 | <productname>systemd</productname> | |
798d3a52 ZJS |
15 | </refentryinfo> |
16 | ||
17 | <refmeta> | |
18 | <refentrytitle>systemd.swap</refentrytitle> | |
19 | <manvolnum>5</manvolnum> | |
20 | </refmeta> | |
21 | ||
22 | <refnamediv> | |
23 | <refname>systemd.swap</refname> | |
24 | <refpurpose>Swap unit configuration</refpurpose> | |
25 | </refnamediv> | |
26 | ||
27 | <refsynopsisdiv> | |
28 | <para><filename><replaceable>swap</replaceable>.swap</filename></para> | |
29 | </refsynopsisdiv> | |
30 | ||
31 | <refsect1> | |
32 | <title>Description</title> | |
33 | ||
34 | <para>A unit configuration file whose name ends in | |
35 | <literal>.swap</literal> encodes information about a swap device | |
36 | or file for memory paging controlled and supervised by | |
37 | systemd.</para> | |
38 | ||
39 | <para>This man page lists the configuration options specific to | |
40 | this unit type. See | |
41 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
42 | for the common options of all unit configuration files. The common | |
43 | configuration items are configured in the generic [Unit] and | |
44 | [Install] sections. The swap specific configuration options are | |
45 | configured in the [Swap] section.</para> | |
46 | ||
47 | <para>Additional options are listed in | |
48 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
c129bd5d LP |
49 | which define the execution environment the <citerefentry |
50 | project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
3f2d1365 | 51 | program is executed in, in |
798d3a52 | 52 | <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
c629ff58 | 53 | which define the way these processes are |
c129bd5d | 54 | terminated, and in |
798d3a52 | 55 | <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
c129bd5d LP |
56 | which configure resource control settings for these processes of the |
57 | unit.</para> | |
798d3a52 | 58 | |
f4bf8d2f LP |
59 | <para>Swap units must be named after the devices or files they control. Example: the swap device <filename |
60 | noindex='true'>/dev/sda5</filename> must be configured in a unit file <filename>dev-sda5.swap</filename>. For | |
61 | details about the escaping logic used to convert a file system path to a unit name, see | |
62 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Note that swap | |
63 | units cannot be templated, nor is possible to add multiple names to a swap unit by creating additional symlinks to | |
64 | it.</para> | |
c129bd5d LP |
65 | </refsect1> |
66 | ||
67 | <refsect1> | |
aed5cb03 ZJS |
68 | <title>Automatic Dependencies</title> |
69 | ||
70 | <refsect2> | |
71 | <title>Implicit Dependencies</title> | |
72 | ||
73 | <para>The following dependencies are implicitly added:</para> | |
74 | ||
75 | <itemizedlist> | |
76 | <listitem><para>All swap units automatically get the | |
77 | <varname>BindsTo=</varname> and <varname>After=</varname> | |
78 | dependencies on the device units or the mount units of the files | |
79 | they are activated from.</para></listitem> | |
80 | </itemizedlist> | |
81 | ||
82 | <para>Additional implicit dependencies may be added as result of | |
83 | execution and resource control parameters as documented in | |
84 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
85 | and | |
86 | <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para> | |
87 | </refsect2> | |
88 | ||
89 | <refsect2> | |
90 | <title>Default Dependencies</title> | |
91 | ||
92 | <para>The following dependencies are added unless <varname>DefaultDependencies=no</varname> is set:</para> | |
93 | ||
94 | <itemizedlist> | |
95 | <listitem><para>Swap units automatically acquire a <varname>Conflicts=</varname> and a | |
96 | <varname>Before=</varname> dependency on <filename>umount.target</filename> so that they are deactivated at | |
97 | shutdown as well as a <varname>Before=swap.target</varname> dependency.</para></listitem> | |
98 | </itemizedlist> | |
99 | </refsect2> | |
45f09f93 JL |
100 | </refsect1> |
101 | ||
798d3a52 ZJS |
102 | <refsect1> |
103 | <title><filename>fstab</filename></title> | |
104 | ||
105 | <para>Swap units may either be configured via unit files, or via | |
106 | <filename>/etc/fstab</filename> (see | |
3ba3a79d | 107 | <citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry> |
798d3a52 ZJS |
108 | for details). Swaps listed in <filename>/etc/fstab</filename> will |
109 | be converted into native units dynamically at boot and when the | |
110 | configuration of the system manager is reloaded. See | |
111 | <citerefentry><refentrytitle>systemd-fstab-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
112 | for details about the conversion.</para> | |
113 | ||
114 | <para>If a swap device or file is configured in both | |
115 | <filename>/etc/fstab</filename> and a unit file, the configuration | |
116 | in the latter takes precedence.</para> | |
117 | ||
b938cb90 | 118 | <para>When reading <filename>/etc/fstab</filename>, a few special |
798d3a52 ZJS |
119 | options are understood by systemd which influence how dependencies |
120 | are created for swap units.</para> | |
121 | ||
122 | <variablelist class='fstab-options'> | |
123 | <varlistentry> | |
124 | <term><option>noauto</option></term> | |
125 | <term><option>auto</option></term> | |
126 | ||
b938cb90 | 127 | <listitem><para>With <option>noauto</option>, the swap unit |
798d3a52 ZJS |
128 | will not be added as a dependency for |
129 | <filename>swap.target</filename>. This means that it will not | |
130 | be activated automatically during boot, unless it is pulled in | |
a8eaaee7 | 131 | by some other unit. The <option>auto</option> option has the |
798d3a52 ZJS |
132 | opposite meaning and is the default.</para> |
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> | |
144 | </listitem> | |
145 | </varlistentry> | |
f0c5cda2 ZJS |
146 | |
147 | <xi:include href="systemd.mount.xml" xpointer="device-timeout" /> | |
148 | ||
149 | <varlistentry> | |
150 | <term><option>x-systemd.makefs</option></term> | |
151 | ||
152 | <listitem><para>The swap structure will be initialized on the device. If the device is not | |
153 | "empty", i.e. it contains any signature, the operation will be skipped. It is hence expected | |
154 | that this option remains set even after the device has been initalized.</para> | |
155 | ||
156 | <para>Note that this option can only be used in <filename>/etc/fstab</filename>, and will be | |
157 | ignored when part of the <varname>Options=</varname> setting in a unit file.</para> | |
158 | ||
159 | <para>See | |
160 | <citerefentry><refentrytitle>systemd-mkswap@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
161 | and the discussion of | |
162 | <citerefentry project='man-pages'><refentrytitle>wipefs</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
163 | in <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>. | |
164 | </para></listitem> | |
165 | </varlistentry> | |
798d3a52 ZJS |
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> | |
19d0833b LP |
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> | |
798d3a52 ZJS |
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 | |
a8eaaee7 JE |
202 | optional and ignored when the priority is set by <option>pri=</option> in the |
203 | <varname>Options=</varname> key.</para></listitem> | |
798d3a52 ZJS |
204 | </varlistentry> |
205 | ||
206 | <varlistentry> | |
207 | <term><varname>Options=</varname></term> | |
208 | ||
d5cc4be2 LP |
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 | |
3ba3a79d | 211 | <citerefentry project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
d5cc4be2 LP |
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> | |
798d3a52 ZJS |
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>, | |
d1698b82 | 248 | <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
798d3a52 ZJS |
249 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
250 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
251 | <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
252 | <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
253 | <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
254 | <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
3ba3a79d | 255 | <citerefentry project='man-pages'><refentrytitle>swapon</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
798d3a52 ZJS |
256 | <citerefentry><refentrytitle>systemd-fstab-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
257 | <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry> | |
258 | </para> | |
259 | </refsect1> | |
e0cabd4b LP |
260 | |
261 | </refentry> |