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