1SWAPON(8) System Administration SWAPON(8)
2
3
4
6 swapon, swapoff - enable/disable devices and files for paging and swap‐
7 ping
8
10 Get info:
11 swapon -s [-h] [-V]
12
13 Enable/disable:
14 swapon [-d] [-f] [-p priority] [-v] specialfile...
15 swapoff [-v] specialfile...
16
17 Enable/disable all:
18 swapon -a [-e] [-f] [-v]
19 swapoff -a [-v]
20
22 swapon is used to specify devices on which paging and swapping are to
23 take place.
24
25 The device or file used is given by the specialfile parameter. It may
26 be of the form -L label or -U uuid to indicate a device by label or
27 uuid.
28
29 Calls to swapon normally occur in the system boot scripts making all
30 swap devices available, so that the paging and swapping activity is
31 interleaved across several devices and files.
32
33 swapoff disables swapping on the specified devices and files. When the
34 -a flag is given, swapping is disabled on all known swap devices and
35 files (as found in /proc/swaps or /etc/fstab).
36
37
38 -a, --all
39 All devices marked as ``swap'' in /etc/fstab are made available,
40 except for those with the ``noauto'' option. Devices that are
41 already being used as swap are silently skipped.
42
43 -d, --discard [=policy]
44 Enable swap discards, if the swap backing device supports the
45 discard or trim operation. This may improve performance on some
46 Solid State Devices, but often it does not. The option allows
47 one to select between two available swap discard policies:
48 --discard=once to perform a single-time discard operation for
49 the whole swap area at swapon; or --discard=pages to discard
50 freed swap pages before they are reused, while swapping. If no
51 policy is selected, the default behavior is to enable both dis‐
52 card types. The /etc/fstab mount options discard, discard=once,
53 or discard=pages may be also used to enable discard flags.
54
55 -e, --ifexists
56 Silently skip devices that do not exist. The /etc/fstab mount
57 option nofail may be also used to skip non-existing device.
58
59
60 -f, --fixpgsz
61 Reinitialize (exec /sbin/mkswap) the swap space if its page size
62 does not match that of the current running kernel. mkswap(2)
63 initializes the whole device and does not check for bad blocks.
64
65 -h, --help
66 Provide help.
67
68 -L label
69 Use the partition that has the specified label. (For this,
70 access to /proc/partitions is needed.)
71
72 -p, --priority priority
73 Specify the priority of the swap device. priority is a value
74 between -1 and 32767. Higher numbers indicate higher priority.
75 See swapon(2) for a full description of swap priorities. Add
76 pri=value to the option field of /etc/fstab for use with swapon
77 -a. When priority is not defined it defaults to -1.
78
79 -s, --summary
80 Display swap usage summary by device. Equivalent to "cat
81 /proc/swaps". Not available before Linux 2.1.25.
82
83 --show [column,column]
84 Display definable device table similar to --summary output. See
85 --help output for column list.
86
87 --noheadings
88 Do not print headings when displaying --show output.
89
90 --raw Display --show output without aligning table columns.
91
92 --bytes
93 Display swap size in bytes in --show output instead of user
94 friendly size and unit. -U uuid Use the partition that has the
95 specified uuid.
96
97 -v, --verbose
98 Be verbose.
99
100 -V, --version
101 Display version.
102
104 You should not use swapon on a file with holes. Swap over NFS may not
105 work.
106
107 swapon automatically detects and rewrites swap space signature with old
108 software suspend data (e.g S1SUSPEND, S2SUSPEND, ...). The problem is
109 that if we don't do it, then we get data corruption the next time an
110 attempt at unsuspending is made.
111
112 swapon may not work correctly when using a swap file with some versions
113 of btrfs. This is due to the swap file implementation in the kernel
114 expecting to be able to write to the file directly, without the assis‐
115 tance of the file system. Since btrfs is a copy-on-write file system,
116 the file location may not be static and corruption can result. Btrfs
117 actively disallows the use of files on its file systems by refusing to
118 map the file. This can be seen in the system log as "swapon: swapfile
119 has holes." One possible workaround is to map the file to a loopback
120 device. This will allow the file system to determine the mapping prop‐
121 erly but may come with a performance impact.
122
123
125 LIBMOUNT_DEBUG=0xffff
126 enables debug output.
127
128
130 swapon(2), swapoff(2), fstab(5), init(8), mkswap(8), rc(8), mount(8)
131
133 /dev/sd?? standard paging devices
134 /etc/fstab ascii filesystem description table
135
137 The swapon command appeared in 4.0BSD.
138
140 The swapon command is part of the util-linux package and is available
141 from ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
142
143
144
145util-linux September 1995 SWAPON(8)