]>
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 | |
0bb7e904 | 38 | .B swapon |
1f94a78c BS |
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 | 85 | available swap discard policies: |
0bb7e904 | 86 | .B \-\-discard=once |
d6387c98 RA |
87 | to perform a single-time discard operation for the whole swap area at swapon; |
88 | or | |
0bb7e904 | 89 | .B \-\-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 |
1895c76f | 191 | .SS Files with holes |
63391d75 MM |
192 | The swap file implementation in the kernel expects to be able to write to the |
193 | file directly, without the assistance of the filesystem. This is a problem on | |
194 | files with holes or on copy-on-write files on filesystems like Btrfs. | |
1895c76f | 195 | .sp |
63391d75 | 196 | Commands like |
eebfa469 | 197 | .BR cp (1) |
1895c76f KZ |
198 | or |
199 | .BR truncate (1) | |
200 | create files with holes. These files will be rejected by swapon. | |
201 | .sp | |
63391d75 MM |
202 | Preallocated files created by |
203 | .BR fallocate (1) | |
204 | may be interpreted as files with holes too depending of the filesystem. | |
205 | Preallocated swap files are supported on XFS since Linux 4.18. | |
1895c76f KZ |
206 | .sp |
207 | The most portable solution to create a swap file is to use | |
24930e70 | 208 | .BR dd (1) |
63391d75 | 209 | and /dev/zero. |
1895c76f | 210 | .SS Btrfs |
63391d75 MM |
211 | Swap files on Btrfs are supported since Linux 5.0 on files with nocow attribute. |
212 | See the | |
213 | .BR btrfs (5) | |
214 | manual page for more details. | |
1895c76f | 215 | .SS NFS |
03b5e597 | 216 | Swap over \fBNFS\fR may not work. |
1895c76f | 217 | .SS Suspend |
1581e22c | 218 | .B swapon |
24930e70 | 219 | automatically detects and rewrites a swap space signature with old software |
b9c3b903 | 220 | suspend data (e.g. S1SUSPEND, S2SUSPEND, ...). The problem is that if we don't |
1581e22c KZ |
221 | do it, then we get data corruption the next time an attempt at unsuspending is |
222 | made. | |
ca3dbca1 | 223 | .SH ENVIRONMENT |
03b5e597 KZ |
224 | .IP LIBMOUNT_DEBUG=all |
225 | enables libmount debug output. | |
68e422ec KZ |
226 | .IP LIBBLKID_DEBUG=all |
227 | enables libblkid debug output. | |
ca3dbca1 | 228 | |
6dbe3af9 | 229 | .SH SEE ALSO |
22853e4a | 230 | .BR swapoff (2), |
f053ff1e | 231 | .BR swapon (2), |
22853e4a KZ |
232 | .BR fstab (5), |
233 | .BR init (8), | |
63391d75 | 234 | .BR fallocate (1), |
22853e4a | 235 | .BR mkswap (8), |
f053ff1e MK |
236 | .BR mount (8), |
237 | .BR rc (8) | |
6dbe3af9 | 238 | .SH FILES |
6dbe3af9 | 239 | .br |
726f69e2 | 240 | .I /dev/sd?? |
1581e22c | 241 | standard paging devices |
6dbe3af9 KZ |
242 | .br |
243 | .I /etc/fstab | |
244 | ascii filesystem description table | |
245 | .SH HISTORY | |
246 | The | |
247 | .B swapon | |
248 | command appeared in 4.0BSD. | |
86d62711 | 249 | .SH AVAILABILITY |
601d12fb | 250 | The swapon command is part of the util-linux package and is available from |
d673b74e | 251 | https://www.kernel.org/pub/linux/utils/util-linux/. |