1SYSTEMD.SWAP(5) systemd.swap SYSTEMD.SWAP(5)
2
3
4
6 systemd.swap - Swap unit configuration
7
9 swap.swap
10
12 A unit configuration file whose name ends in ".swap" encodes
13 information about a swap device or file for memory paging controlled
14 and supervised by systemd.
15
16 This man page lists the configuration options specific to this unit
17 type. See systemd.unit(5) for the common options of all unit
18 configuration files. The common configuration items are configured in
19 the generic "[Unit]" and "[Install]" sections. The swap specific
20 configuration options are configured in the "[Swap]" section.
21
22 Additional options are listed in systemd.exec(5), which define the
23 execution environment the swapon(8) program is executed in, in
24 systemd.kill(5), which define the way these processes are terminated,
25 and in systemd.resource-control(5), which configure resource control
26 settings for these processes of the unit.
27
28 Swap units must be named after the devices or files they control.
29 Example: the swap device /dev/sda5 must be configured in a unit file
30 dev-sda5.swap. For details about the escaping logic used to convert a
31 file system path to a unit name, see systemd.unit(5). Note that swap
32 units cannot be templated, nor is possible to add multiple names to a
33 swap unit by creating additional symlinks to it.
34
36 Implicit Dependencies
37 The following dependencies are implicitly added:
38
39 · All swap units automatically get the BindsTo= and After=
40 dependencies on the device units or the mount units of the files
41 they are activated from.
42
43 Additional implicit dependencies may be added as result of execution
44 and resource control parameters as documented in systemd.exec(5) and
45 systemd.resource-control(5).
46
47 Default Dependencies
48 The following dependencies are added unless DefaultDependencies=no is
49 set:
50
51 · Swap units automatically acquire a Conflicts= and a Before=
52 dependency on umount.target so that they are deactivated at
53 shutdown as well as a Before=swap.target dependency.
54
56 Swap units may either be configured via unit files, or via /etc/fstab
57 (see fstab(5) for details). Swaps listed in /etc/fstab will be
58 converted into native units dynamically at boot and when the
59 configuration of the system manager is reloaded. See systemd-fstab-
60 generator(8) for details about the conversion.
61
62 If a swap device or file is configured in both /etc/fstab and a unit
63 file, the configuration in the latter takes precedence.
64
65 When reading /etc/fstab, a few special options are understood by
66 systemd which influence how dependencies are created for swap units.
67
68 noauto, auto
69 With noauto, the swap unit will not be added as a dependency for
70 swap.target. This means that it will not be activated automatically
71 during boot, unless it is pulled in by some other unit. The auto
72 option has the opposite meaning and is the default.
73
74 nofail
75 With nofail, the swap unit will be only wanted, not required by
76 swap.target. This means that the boot will continue even if this
77 swap device is not activated successfully.
78
79 x-systemd.device-timeout=
80 Configure how long systemd should wait for a device to show up
81 before giving up on an entry from /etc/fstab. Specify a time in
82 seconds or explicitly append a unit such as "s", "min", "h", "ms".
83
84 Note that this option can only be used in /etc/fstab, and will be
85 ignored when part of the Options= setting in a unit file.
86
87 x-systemd.makefs
88 The swap structure will be initialized on the device. If the device
89 is not "empty", i.e. it contains any signature, the operation will
90 be skipped. It is hence expected that this option remains set even
91 after the device has been initialized.
92
93 Note that this option can only be used in /etc/fstab, and will be
94 ignored when part of the Options= setting in a unit file.
95
96 See systemd-mkswap@.service(8) and the discussion of wipefs(8) in
97 systemd.mount(5).
98
100 Swap files must include a [Swap] section, which carries information
101 about the swap device it supervises. A number of options that may be
102 used in this section are shared with other unit types. These options
103 are documented in systemd.exec(5) and systemd.kill(5). The options
104 specific to the [Swap] section of swap units are the following:
105
106 What=
107 Takes an absolute path of a device node or file to use for paging.
108 See swapon(8) for details. If this refers to a device node, a
109 dependency on the respective device unit is automatically created.
110 (See systemd.device(5) for more information.) If this refers to a
111 file, a dependency on the respective mount unit is automatically
112 created. (See systemd.mount(5) for more information.) This option
113 is mandatory. Note that the usual specifier expansion is applied to
114 this setting, literal percent characters should hence be written as
115 "%%".
116
117 Priority=
118 Swap priority to use when activating the swap device or file. This
119 takes an integer. This setting is optional and ignored when the
120 priority is set by pri= in the Options= key.
121
122 Options=
123 May contain an option string for the swap device. This may be used
124 for controlling discard options among other functionality, if the
125 swap backing device supports the discard or trim operation. (See
126 swapon(8) for more information.) Note that the usual specifier
127 expansion is applied to this setting, literal percent characters
128 should hence be written as "%%".
129
130 TimeoutSec=
131 Configures the time to wait for the swapon command to finish. If a
132 command does not exit within the configured time, the swap will be
133 considered failed and be shut down again. All commands still
134 running will be terminated forcibly via SIGTERM, and after another
135 delay of this time with SIGKILL. (See KillMode= in
136 systemd.kill(5).) Takes a unit-less value in seconds, or a time
137 span value such as "5min 20s". Pass "0" to disable the timeout
138 logic. Defaults to DefaultTimeoutStartSec= from the manager
139 configuration file (see systemd-system.conf(5)).
140
141 Check systemd.exec(5) and systemd.kill(5) for more settings.
142
144 systemd(1), systemctl(1), systemd-system.conf(5), systemd.unit(5),
145 systemd.exec(5), systemd.kill(5), systemd.resource-control(5),
146 systemd.device(5), systemd.mount(5), swapon(8), systemd-fstab-
147 generator(8), systemd.directives(7)
148
149
150
151systemd 245 SYSTEMD.SWAP(5)