1 .\" Copyright (c) 1980, 1991 Regents of the University of California.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)swapon.8 6.3 (Berkeley) 3/16/91
34 .TH SWAPON 8 "October 2014" "util-linux" "System Administration"
36 swapon, swapoff \- enable/disable devices and files for paging and swapping
40 .RI [ specialfile ...]
44 .RI [ specialfile ...]
47 is used to specify devices on which paging and swapping are to take place.
49 The device or file used is given by the
51 parameter. It may be of the form
55 to indicate a device by label or uuid.
59 normally occur in the system boot scripts making all swap devices available, so
60 that the paging and swapping activity is interleaved across several devices and
64 disables swapping on the specified devices and files.
67 flag is given, swapping is disabled on all known swap devices and files
76 All devices marked as ``swap'' in
78 are made available, except for those with the ``noauto'' option.
79 Devices that are already being used as swap are silently skipped.
81 .BR \-d , " \-\-discard" [ =\fIpolicy\fR]
82 Enable swap discards, if the swap backing device supports the discard or
83 trim operation. This may improve performance on some Solid State Devices,
84 but often it does not. The option allows one to select between two
85 available swap discard policies:
87 to perform a single-time discard operation for the whole swap area at swapon;
90 to asynchronously discard freed swap pages before they are available for reuse.
91 If no policy is selected, the default behavior is to enable both discard types.
99 may also be used to enable discard flags.
101 .BR \-e , " \-\-ifexists"
102 Silently skip devices that do not exist.
107 may also be used to skip non-existing device.
110 .BR \-f , " \-\-fixpgsz"
111 Reinitialize (exec mkswap) the swap space if its page size does not
112 match that of the current running kernel.
114 initializes the whole device and does not check for bad blocks.
116 .BR \-h , " \-\-help"
117 Display help text and exit.
120 Use the partition that has the specified
126 .BR \-o , " \-\-options " \fIopts\fP
127 Specify swap options by an fstab-compatible comma-separated string.
132 .B "swapon -o pri=1,discard=pages,nofail /dev/sda2"
135 The \fIopts\fP string is evaluated last and overrides all other
136 command line options.
139 .BR \-p , " \-\-priority " \fIpriority\fP
140 Specify the priority of the swap device.
142 is a value between \-1 and 32767. Higher numbers indicate
145 for a full description of swap priorities. Add
147 to the option field of
151 When no priority is defined, it defaults to \-1.
153 .BR \-s , " \-\-summary"
154 Display swap usage summary by device. Equivalent to "cat /proc/swaps".
155 This output format is DEPRECATED in favour
156 of \fB\-\-show\fR that provides better control on output data.
158 .BR \-\-show [ =\fIcolumn\fR ...]
159 Display a definable table of swap areas. See the
161 output for a list of available columns.
164 Do not print headings when displaying
171 output without aligning table columns.
174 Display swap size in bytes in
176 output instead of in user-friendly units.
179 Use the partition that has the specified
182 .BR \-v , " \-\-verbose"
185 .BR \-V , " \-\-version"
186 Display version information and exit.
188 You should not use \fBswapon\fR on a file with holes.
189 This can be seen in the system log as
192 .B "swapon: swapfile has holes."
195 The swap file implementation in the kernel expects to be able to write to the
196 file directly, without the assistance of the filesystem. This is a problem on
197 preallocated files (e.g.
199 on filesystems like \fBXFS\fR or \fBext4\fR, and on copy-on-write
200 filesystems like \fBbtrfs\fR.
202 It is recommended to use
206 to avoid holes on XFS and ext4.
209 may not work correctly when using a swap file with some versions of
210 \fBbtrfs\fR. This is due to btrfs being a copy-on-write filesystem: the
211 file location may not be static and corruption can result. Btrfs actively
212 disallows the use of swap files on its filesystems by refusing to map the file.
214 One possible workaround is to map the swap
215 file to a loopback device. This will allow the filesystem to determine the
216 mapping properly but may come with a performance impact.
218 Swap over \fBNFS\fR may not work.
221 automatically detects and rewrites a swap space signature with old software
222 suspend data (e.g S1SUSPEND, S2SUSPEND, ...). The problem is that if we don't
223 do it, then we get data corruption the next time an attempt at unsuspending is
227 .IP LIBMOUNT_DEBUG=all
228 enables libmount debug output.
229 .IP LIBBLKID_DEBUG=all
230 enables libblkid debug output.
243 standard paging devices
246 ascii filesystem description table
250 command appeared in 4.0BSD.
252 The swapon command is part of the util-linux package and is available from
253 https://www.kernel.org/pub/linux/utils/util-linux/.