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