]>
Commit | Line | Data |
---|---|---|
6dbe3af9 KZ |
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 | .\" | |
b1301d78 | 34 | .TH SWAPON 8 "October 2014" "util-linux" "System Administration" |
6dbe3af9 KZ |
35 | .SH NAME |
36 | swapon, swapoff \- enable/disable devices and files for paging and swapping | |
37 | .SH SYNOPSIS | |
1f94a78c BS |
38 | .BR swapon |
39 | [options] | |
40 | .RI [ specialfile ...] | |
fd6b7a7f | 41 | .br |
1581e22c | 42 | .B swapoff |
7bed68bf | 43 | .RB [ \-va ] |
1f94a78c | 44 | .RI [ specialfile ...] |
6dbe3af9 | 45 | .SH DESCRIPTION |
ce6479e2 | 46 | .B swapon |
6dbe3af9 | 47 | is used to specify devices on which paging and swapping are to take place. |
756bfd01 KZ |
48 | |
49 | The device or file used is given by the | |
50 | .I specialfile | |
1f94a78c | 51 | parameter. It may be of the form |
756bfd01 KZ |
52 | .BI \-L " label" |
53 | or | |
54 | .BI \-U " uuid" | |
55 | to indicate a device by label or uuid. | |
56 | ||
6dbe3af9 KZ |
57 | Calls to |
58 | .B swapon | |
1581e22c KZ |
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 | |
61 | files. | |
6dbe3af9 | 62 | |
1581e22c KZ |
63 | .B swapoff |
64 | disables swapping on the specified devices and files. | |
65 | When the | |
6dbe3af9 | 66 | .B \-a |
1581e22c KZ |
67 | flag is given, swapping is disabled on all known swap devices and files |
68 | (as found in | |
69 | .I /proc/swaps | |
70 | or | |
71 | .IR /etc/fstab ). | |
72 | ||
1f94a78c | 73 | .SH OPTIONS |
1581e22c | 74 | .TP |
1f94a78c | 75 | .BR \-a , " \-\-all" |
ce6479e2 | 76 | All devices marked as ``swap'' in |
6dbe3af9 | 77 | .I /etc/fstab |
d162fcb5 | 78 | are made available, except for those with the ``noauto'' option. |
ce6479e2 | 79 | Devices that are already being used as swap are silently skipped. |
c2301380 | 80 | .TP |
1f94a78c | 81 | .BR \-d , " \-\-discard" [ =\fIpolicy\fR] |
d6387c98 | 82 | Enable swap discards, if the swap backing device supports the discard or |
1f94a78c BS |
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 | |
d6387c98 RA |
85 | available swap discard policies: |
86 | .BI \-\-discard=once | |
87 | to perform a single-time discard operation for the whole swap area at swapon; | |
88 | or | |
89 | .BI \-\-discard=pages | |
d35df4db | 90 | to asynchronously discard freed swap pages before they are available for reuse. |
d6387c98 | 91 | If no policy is selected, the default behavior is to enable both discard types. |
c2301380 HD |
92 | The |
93 | .I /etc/fstab | |
d6387c98 | 94 | mount options |
1f94a78c BS |
95 | .BR discard , |
96 | .BR discard=once , | |
d6387c98 | 97 | or |
1f94a78c BS |
98 | .B discard=pages |
99 | may also be used to enable discard flags. | |
302e7b18 | 100 | .TP |
1f94a78c | 101 | .BR \-e , " \-\-ifexists" |
ce6479e2 | 102 | Silently skip devices that do not exist. |
a5fd3d68 KZ |
103 | The |
104 | .I /etc/fstab | |
105 | mount option | |
1f94a78c BS |
106 | .B nofail |
107 | may also be used to skip non-existing device. | |
a5fd3d68 | 108 | |
756bfd01 | 109 | .TP |
1f94a78c | 110 | .BR \-f , " \-\-fixpgsz" |
f1bc5996 | 111 | Reinitialize (exec mkswap) the swap space if its page size does not |
8d8ea18e | 112 | match that of the current running kernel. |
8323d9fd | 113 | .BR mkswap (2) |
0d761944 KZ |
114 | initializes the whole device and does not check for bad blocks. |
115 | .TP | |
1f94a78c | 116 | .BR \-h , " \-\-help" |
b4362b6f | 117 | Display help text and exit. |
756bfd01 | 118 | .TP |
1f94a78c | 119 | .BI \-L " label" |
756bfd01 KZ |
120 | Use the partition that has the specified |
121 | .IR label . | |
122 | (For this, access to | |
123 | .I /proc/partitions | |
124 | is needed.) | |
726f69e2 | 125 | .TP |
e07fdac4 | 126 | .BR \-o , " \-\-options " \fIopts\fP |
b1301d78 BS |
127 | Specify swap options by an fstab-compatible comma-separated string. |
128 | For example: | |
e07fdac4 KZ |
129 | .RS |
130 | .RS | |
131 | .sp | |
132 | .B "swapon -o pri=1,discard=pages,nofail /dev/sda2" | |
133 | .sp | |
134 | .RE | |
b1301d78 | 135 | The \fIopts\fP string is evaluated last and overrides all other |
6c44094a | 136 | command line options. |
e07fdac4 KZ |
137 | .RE |
138 | .TP | |
1f94a78c | 139 | .BR \-p , " \-\-priority " \fIpriority\fP |
1581e22c | 140 | Specify the priority of the swap device. |
fd6b7a7f | 141 | .I priority |
9404a96a SK |
142 | is a value between \-1 and 32767. Higher numbers indicate |
143 | higher priority. See | |
fd6b7a7f | 144 | .BR swapon (2) |
1f94a78c | 145 | for a full description of swap priorities. Add |
fd6b7a7f KZ |
146 | .BI pri= value |
147 | to the option field of | |
148 | .I /etc/fstab | |
149 | for use with | |
150 | .BR "swapon -a" . | |
b1301d78 | 151 | When no priority is defined, it defaults to \-1. |
a47f2e66 | 152 | .TP |
1f94a78c BS |
153 | .BR \-s , " \-\-summary" |
154 | Display swap usage summary by device. Equivalent to "cat /proc/swaps". | |
9f3d0fce | 155 | This output format is DEPRECATED in favour |
a6c6662d | 156 | of \fB\-\-show\fR that provides better control on output data. |
756bfd01 | 157 | .TP |
b1301d78 BS |
158 | .BR \-\-show [ =\fIcolumn\fR ...] |
159 | Display a definable table of swap areas. See the | |
1f94a78c BS |
160 | .B \-\-help |
161 | output for a list of available columns. | |
e076b552 | 162 | .TP |
b5b43f27 SK |
163 | .B \-\-output\-all |
164 | Output all available columns. | |
165 | .TP | |
e076b552 SK |
166 | .B \-\-noheadings |
167 | Do not print headings when displaying | |
168 | .B \-\-show | |
169 | output. | |
170 | .TP | |
171 | .B \-\-raw | |
172 | Display | |
173 | .B \-\-show | |
174 | output without aligning table columns. | |
175 | .TP | |
a68ca3a1 | 176 | .B \-\-bytes |
7ae8b469 SK |
177 | Display swap size in bytes in |
178 | .B \-\-show | |
1f94a78c BS |
179 | output instead of in user-friendly units. |
180 | .TP | |
181 | .BI \-U " uuid" | |
756bfd01 KZ |
182 | Use the partition that has the specified |
183 | .IR uuid . | |
756bfd01 | 184 | .TP |
b1301d78 | 185 | .BR \-v , " \-\-verbose" |
a47f2e66 | 186 | Be verbose. |
756bfd01 | 187 | .TP |
b1301d78 | 188 | .BR \-V , " \-\-version" |
b4362b6f | 189 | Display version information and exit. |
1581e22c | 190 | .SH NOTES |
24930e70 BS |
191 | You should not use \fBswapon\fR on a file with holes. |
192 | This can be seen in the system log as | |
03b5e597 KZ |
193 | .RS |
194 | .sp | |
195 | .B "swapon: swapfile has holes." | |
196 | .sp | |
197 | .RE | |
24930e70 BS |
198 | The swap file implementation in the kernel expects to be able to write to the |
199 | file directly, without the assistance of the filesystem. This is a problem on | |
03b5e597 | 200 | preallocated files (e.g. |
24930e70 BS |
201 | .BR fallocate (1)) |
202 | on filesystems like \fBXFS\fR or \fBext4\fR, and on copy-on-write | |
203 | filesystems like \fBbtrfs\fR. | |
03b5e597 KZ |
204 | .PP |
205 | It is recommended to use | |
24930e70 | 206 | .BR dd (1) |
03b5e597 KZ |
207 | and |
208 | .I /dev/zero | |
209 | to avoid holes on XFS and ext4. | |
210 | .PP | |
5c36a0eb | 211 | .B swapon |
03b5e597 | 212 | may not work correctly when using a swap file with some versions of |
24930e70 | 213 | \fBbtrfs\fR. This is due to btrfs being a copy-on-write filesystem: the |
03b5e597 | 214 | file location may not be static and corruption can result. Btrfs actively |
24930e70 | 215 | disallows the use of swap files on its filesystems by refusing to map the file. |
03b5e597 | 216 | .PP |
24930e70 BS |
217 | One possible workaround is to map the swap |
218 | file to a loopback device. This will allow the filesystem to determine the | |
03b5e597 KZ |
219 | mapping properly but may come with a performance impact. |
220 | .PP | |
221 | Swap over \fBNFS\fR may not work. | |
1581e22c KZ |
222 | .PP |
223 | .B swapon | |
24930e70 | 224 | automatically detects and rewrites a swap space signature with old software |
1581e22c KZ |
225 | suspend data (e.g S1SUSPEND, S2SUSPEND, ...). The problem is that if we don't |
226 | do it, then we get data corruption the next time an attempt at unsuspending is | |
227 | made. | |
26907ffa | 228 | |
ca3dbca1 | 229 | .SH ENVIRONMENT |
03b5e597 KZ |
230 | .IP LIBMOUNT_DEBUG=all |
231 | enables libmount debug output. | |
68e422ec KZ |
232 | .IP LIBBLKID_DEBUG=all |
233 | enables libblkid debug output. | |
ca3dbca1 | 234 | |
6dbe3af9 | 235 | .SH SEE ALSO |
22853e4a | 236 | .BR swapoff (2), |
f053ff1e | 237 | .BR swapon (2), |
22853e4a KZ |
238 | .BR fstab (5), |
239 | .BR init (8), | |
240 | .BR mkswap (8), | |
f053ff1e MK |
241 | .BR mount (8), |
242 | .BR rc (8) | |
6dbe3af9 | 243 | .SH FILES |
6dbe3af9 | 244 | .br |
726f69e2 | 245 | .I /dev/sd?? |
1581e22c | 246 | standard paging devices |
6dbe3af9 KZ |
247 | .br |
248 | .I /etc/fstab | |
249 | ascii filesystem description table | |
250 | .SH HISTORY | |
251 | The | |
252 | .B swapon | |
253 | command appeared in 4.0BSD. | |
86d62711 | 254 | .SH AVAILABILITY |
601d12fb | 255 | The swapon command is part of the util-linux package and is available from |
d673b74e | 256 | https://www.kernel.org/pub/linux/utils/util-linux/. |