]> git.ipfire.org Git - thirdparty/util-linux.git/blob - sys-utils/swapon.8
docs: standardize the phrases for --help and --version in all man pages
[thirdparty/util-linux.git] / sys-utils / swapon.8
1 .\" Copyright (c) 1980, 1991 Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
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.
19 .\"
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
30 .\" SUCH DAMAGE.
31 .\"
32 .\" @(#)swapon.8 6.3 (Berkeley) 3/16/91
33 .\"
34 .\" Sun Dec 27 12:31:30 1992: Modified by faith@cs.unc.edu
35 .\" Sat Mar 6 20:46:02 1993: Modified by faith@cs.unc.edu
36 .\" Sat Oct 9 09:35:30 1993: Converted to man format by faith@cs.unc.edu
37 .\" Sat Nov 27 20:22:42 1993: Updated authorship information, faith@cs.unc.edu
38 .\" Mon Sep 25 14:12:38 1995: Added -v and -p information
39 .\" Tue Apr 30 03:32:07 1996: Added some text from A. Koppenhoefer
40 .\"
41 .TH SWAPON 8 "September 1995" "util-linux" "System Administration"
42 .SH NAME
43 swapon, swapoff \- enable/disable devices and files for paging and swapping
44 .SH SYNOPSIS
45 .B swapon
46 [ options ]
47 .RI [ specialfile... ]
48 .br
49 .B swapoff
50 .RB [ \-va ]
51 .RI [ specialfile... ]
52 .SH DESCRIPTION
53 .B swapon
54 is used to specify devices on which paging and swapping are to take place.
55
56 The device or file used is given by the
57 .I specialfile
58 parameter. It may be of the form
59 .BI \-L " label"
60 or
61 .BI \-U " uuid"
62 to indicate a device by label or uuid.
63
64 Calls to
65 .B swapon
66 normally occur in the system boot scripts making all swap devices available, so
67 that the paging and swapping activity is interleaved across several devices and
68 files.
69
70 .B swapoff
71 disables swapping on the specified devices and files.
72 When the
73 .B \-a
74 flag is given, swapping is disabled on all known swap devices and files
75 (as found in
76 .I /proc/swaps
77 or
78 .IR /etc/fstab ).
79
80 .TP
81 .B "\-a, \-\-all"
82 All devices marked as ``swap'' in
83 .I /etc/fstab
84 are made available, except for those with the ``noauto'' option.
85 Devices that are already being used as swap are silently skipped.
86 .TP
87 .B "\-d, \-\-discard\fR [=\fIpolicy\fR]"
88 Enable swap discards, if the swap backing device supports the discard or
89 trim operation. This may improve performance on some Solid State Devices,
90 but often it does not. The option allows one to select between two
91 available swap discard policies:
92 .BI \-\-discard=once
93 to perform a single-time discard operation for the whole swap area at swapon;
94 or
95 .BI \-\-discard=pages
96 to discard freed swap pages before they are reused, while swapping.
97 If no policy is selected, the default behavior is to enable both discard types.
98 The
99 .I /etc/fstab
100 mount options
101 .BI discard,
102 .BI discard=once,
103 or
104 .BI discard=pages
105 may be also used to enable discard flags.
106 .TP
107 .B "\-e, \-\-ifexists"
108 Silently skip devices that do not exist.
109 The
110 .I /etc/fstab
111 mount option
112 .BI nofail
113 may be also used to skip non-existing device.
114
115 .TP
116 .B "\-f, \-\-fixpgsz"
117 Reinitialize (exec /sbin/mkswap) the swap space if its page size does not
118 match that of the current running kernel.
119 .BR mkswap (2)
120 initializes the whole device and does not check for bad blocks.
121 .TP
122 .B \-h, \-\-help
123 Display help text and exit.
124 .TP
125 .B "\-L \fIlabel\fP"
126 Use the partition that has the specified
127 .IR label .
128 (For this, access to
129 .I /proc/partitions
130 is needed.)
131 .TP
132 .B "\-p, \-\-priority \fIpriority\fP"
133 Specify the priority of the swap device.
134 .I priority
135 is a value between \-1 and 32767. Higher numbers indicate
136 higher priority. See
137 .BR swapon (2)
138 for a full description of swap priorities. Add
139 .BI pri= value
140 to the option field of
141 .I /etc/fstab
142 for use with
143 .BR "swapon -a" .
144 When priority is not defined it defaults to \-1.
145 .TP
146 .B "\-s, \-\-summary"
147 Display swap usage summary by device. Equivalent to "cat /proc/swaps".
148 Not available before Linux 2.1.25.
149 .TP
150 \fB\-\-show\fR [\fIcolumn\fR, ...]
151 Display definable device table similar to
152 .B \-\-summary
153 output. See \-\-help output for
154 .I column
155 list.
156 .TP
157 .B \-\-noheadings
158 Do not print headings when displaying
159 .B \-\-show
160 output.
161 .TP
162 .B \-\-raw
163 Display
164 .B \-\-show
165 output without aligning table columns.
166 .TP
167 .B \-\-bytes
168 Display swap size in bytes in
169 .B \-\-show
170 output instead of user friendly size and unit.
171 .B "\-U \fIuuid\fP"
172 Use the partition that has the specified
173 .IR uuid .
174 .TP
175 .B "\-v, \-\-verbose"
176 Be verbose.
177 .TP
178 .B "\-V, \-\-version"
179 Display version information and exit.
180 .SH NOTES
181 You should not use
182 .B swapon
183 on a file with holes.
184 Swap over NFS may not work.
185 .PP
186 .B swapon
187 automatically detects and rewrites swap space signature with old software
188 suspend data (e.g S1SUSPEND, S2SUSPEND, ...). The problem is that if we don't
189 do it, then we get data corruption the next time an attempt at unsuspending is
190 made.
191 .PP
192 .B swapon
193 may not work correctly when using a swap file with some versions of btrfs.
194 This is due to the swap file implementation in the kernel expecting to be able
195 to write to the file directly, without the assistance of the file system.
196 Since btrfs is a copy-on-write file system, the file location may not be
197 static and corruption can result. Btrfs actively disallows the use of files
198 on its file systems by refusing to map the file. This can be seen in the system
199 log as "swapon: swapfile has holes." One possible workaround is to map the
200 file to a loopback device. This will allow the file system to determine the
201 mapping properly but may come with a performance impact.
202
203 .SH ENVIRONMENT
204 .IP LIBMOUNT_DEBUG=0xffff
205 enables debug output.
206
207 .SH SEE ALSO
208 .BR swapon (2),
209 .BR swapoff (2),
210 .BR fstab (5),
211 .BR init (8),
212 .BR mkswap (8),
213 .BR rc (8),
214 .BR mount (8)
215 .SH FILES
216 .br
217 .I /dev/sd??
218 standard paging devices
219 .br
220 .I /etc/fstab
221 ascii filesystem description table
222 .SH HISTORY
223 The
224 .B swapon
225 command appeared in 4.0BSD.
226 .SH AVAILABILITY
227 The swapon command is part of the util-linux package and is available from
228 ftp://ftp.kernel.org/pub/linux/utils/util-linux/.