1SWAPON(8)                    System Administration                   SWAPON(8)
2
3
4

NAME

6       swapon, swapoff - enable/disable devices and files for paging and swap‐
7       ping
8

SYNOPSIS

10       swapon [options] [specialfile...]
11       swapoff [-va] [specialfile...]
12

DESCRIPTION

14       swapon is used to specify devices on which paging and swapping  are  to
15       take place.
16
17       The  device or file used is given by the specialfile parameter.  It may
18       be of the form -L label or -U uuid to indicate a  device  by  label  or
19       uuid.
20
21       Calls  to  swapon  normally occur in the system boot scripts making all
22       swap devices available, so that the paging  and  swapping  activity  is
23       interleaved across several devices and files.
24
25       swapoff disables swapping on the specified devices and files.  When the
26       -a flag is given, swapping is disabled on all known  swap  devices  and
27       files (as found in /proc/swaps or /etc/fstab).
28
29

OPTIONS

31       -a, --all
32              All devices marked as ``swap'' in /etc/fstab are made available,
33              except for those with the ``noauto'' option.  Devices  that  are
34              already being used as swap are silently skipped.
35
36       -d, --discard[=policy]
37              Enable  swap  discards,  if the swap backing device supports the
38              discard or trim operation.  This may improve performance on some
39              Solid  State  Devices, but often it does not.  The option allows
40              one to select  between  two  available  swap  discard  policies:
41              --discard=once  to  perform  a single-time discard operation for
42              the whole swap area  at  swapon;  or  --discard=pages  to  asyn‐
43              chronously  discard  freed  swap pages before they are available
44              for reuse.  If no policy is selected, the default behavior is to
45              enable  both  discard  types.  The /etc/fstab mount options dis‐
46              card, discard=once, or discard=pages may also be used to  enable
47              discard flags.
48
49       -e, --ifexists
50              Silently  skip  devices that do not exist.  The /etc/fstab mount
51              option nofail may also be used to skip non-existing device.
52
53
54       -f, --fixpgsz
55              Reinitialize (exec mkswap) the swap space if its page size  does
56              not  match  that  of the current running kernel.  mkswap(2) ini‐
57              tializes the whole device and does not check for bad blocks.
58
59       -h, --help
60              Display help text and exit.
61
62       -L label
63              Use the partition that has  the  specified  label.   (For  this,
64              access to /proc/partitions is needed.)
65
66       -o, --options opts
67              Specify  swap  options  by  an  fstab-compatible comma-separated
68              string.  For example:
69
70                     swapon -o pri=1,discard=pages,nofail /dev/sda2
71
72              The opts string is evaluated last and overrides all  other  com‐
73              mand line options.
74
75       -p, --priority priority
76              Specify  the  priority  of the swap device.  priority is a value
77              between -1 and 32767.  Higher numbers indicate higher  priority.
78              See  swapon(2)  for  a full description of swap priorities.  Add
79              pri=value to the option field of /etc/fstab for use with  swapon
80              -a.  When no priority is defined, it defaults to -1.
81
82       -s, --summary
83              Display  swap  usage  summary  by  device.   Equivalent  to "cat
84              /proc/swaps".  This output format is  DEPRECATED  in  favour  of
85              --show that provides better control on output data.
86
87       --show[=column...]
88              Display  a definable table of swap areas.  See the --help output
89              for a list of available columns.
90
91       --output-all
92              Output all available columns.
93
94       --noheadings
95              Do not print headings when displaying --show output.
96
97       --raw  Display --show output without aligning table columns.
98
99       --bytes
100              Display swap size in bytes in --show output instead of in  user-
101              friendly units.
102
103       -U uuid
104              Use the partition that has the specified uuid.
105
106       -v, --verbose
107              Be verbose.
108
109       -V, --version
110              Display version information and exit.
111

NOTES

113   Files with holes
114       The  swap file implementation in the kernel expects to be able to write
115       to the file directly, without the assistance of the  filesystem.   This
116       is  a problem on files with holes or on copy-on-write files on filesys‐
117       tems like Btrfs.
118
119       Commands like cp(1) or truncate(1)  create  files  with  holes.   These
120       files will be rejected by swapon.
121
122       Preallocated  files created by fallocate(1) may be interpreted as files
123       with holes too depending of the filesystem.   Preallocated  swap  files
124       are supported on XFS since Linux 4.18.
125
126       The  most  portable  solution to create a swap file is to use dd(1) and
127       /dev/zero.
128
129   Btrfs
130       Swap files on Btrfs are supported since Linux 5.0 on files  with  nocow
131       attribute.  See the btrfs(5) manual page for more details.
132
133   NFS
134       Swap over NFS may not work.
135
136   Suspend
137       swapon  automatically  detects and rewrites a swap space signature with
138       old software suspend data (e.g. S1SUSPEND, S2SUSPEND, ...). The problem
139       is that if we don't do it, then we get data corruption the next time an
140       attempt at unsuspending is made.
141

ENVIRONMENT

143       LIBMOUNT_DEBUG=all
144              enables libmount debug output.
145
146       LIBBLKID_DEBUG=all
147              enables libblkid debug output.
148
149

SEE ALSO

151       swapoff(2),  swapon(2),  fstab(5),  init(8),  fallocate(1),  mkswap(8),
152       mount(8), rc(8)
153

FILES

155       /dev/sd??  standard paging devices
156       /etc/fstab ascii filesystem description table
157

HISTORY

159       The swapon command appeared in 4.0BSD.
160

AVAILABILITY

162       The  swapon  command is part of the util-linux package and is available
163       from https://www.kernel.org/pub/linux/utils/util-linux/.
164
165
166
167util-linux                       October 2014                        SWAPON(8)
Impressum