xref: /freebsd/sbin/swapon/swapon.8 (revision 783d3ff6d7fae619db8a7990b8a6387de0c677b5)
1.\" Copyright (c) 1980, 1991, 1993
2.\"	The Regents of the University of California.  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. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd November 29, 2021
29.Dt SWAPON 8
30.Os
31.Sh NAME
32.Nm swapon , swapoff , swapctl
33.Nd "specify devices for paging and swapping"
34.Sh SYNOPSIS
35.Nm swapon
36.Oo Fl F Ar fstab
37.Oc
38.Fl aLq | E Ar
39.Nm swapoff
40.Oo Fl F Ar fstab
41.Oc
42.Fl afLq | Ar
43.Nm swapctl
44.Op Fl AfghklmsU
45.Oo
46.Fl a Ar
47|
48.Fl d Ar
49.Oc
50.Sh DESCRIPTION
51The
52.Nm swapon , swapoff
53and
54.Nm swapctl
55utilities are used to control swap devices in the system.
56At boot time all swap entries in
57.Pa /etc/fstab
58are added automatically when the system goes multi-user.
59Swap devices use a fixed interleave; the maximum number of devices
60is unlimited.
61There is no priority mechanism.
62.Pp
63The
64.Nm swapon
65utility adds the specified swap devices to the system.
66If the
67.Fl a
68option is used, all swap devices in
69.Pa /etc/fstab
70will be added, unless their
71.Dq noauto
72or
73.Dq late
74option is also set.
75If the
76.Fl L
77option is specified,
78swap devices with the
79.Dq late
80option will be added as well as ones with no option.
81If the
82.Fl q
83option is used,
84informational messages will not be
85written to standard output when a swap device is added.
86The
87.Fl E
88option causes each of following devices to receive a
89.Dv BIO_DELETE
90command.
91This command marks the device's blocks as unused, except those that
92might store a disk label.
93This marking can erase a crash dump.
94To delay
95.Nm swapon
96for a device until after
97.Nm savecore
98has copied the crash dump to another location, use the
99.Dq late
100option.
101.Pp
102The
103.Nm swapoff
104utility removes the specified swap devices from the system.
105If the
106.Fl a
107option is used, all swap devices in
108.Pa /etc/fstab
109will be removed, unless their
110.Dq noauto
111option is also set.
112If the
113.Fl L
114option is specified,
115only swap devices with the
116.Dq late
117option will be removed.
118If the
119.Fl q
120option is used,
121informational messages will not be
122written to standard output when a swap device is removed.
123Note that
124.Nm swapoff
125will fail and refuse to remove a swap device if a very conservative
126check does not conclude that there is sufficient VM (memory +
127remaining swap devices) to run the system.
128The
129.Fl f
130option turns off this check, which could deadlock the system
131if there is insufficient swap space remaining.
132.Pp
133The
134.Nm swapoff
135utility
136must move swapped pages out of the device being removed which could
137lead to high system loads for a period of time, depending on how
138much data has been swapped out to that device.
139.Pp
140Other options supported by both
141.Nm swapon
142and
143.Nm swapoff
144are as follows:
145.Bl -tag -width indent
146.It Fl F Ar fstab
147Specify the
148.Pa fstab
149file to use (in conjunction with
150.Fl a Ns ).
151.El
152.Pp
153The
154.Nm swapctl
155utility exists primarily for those familiar with other
156.Bx Ns s
157and may be
158used to add, remove, or list swap devices.
159Note that the
160.Fl a
161option is used differently in
162.Nm swapctl
163and indicates that a specific list of devices should be added.
164The
165.Fl d
166option indicates that a specific list should be removed.
167The
168.Fl A
169and
170.Fl U
171options to
172.Nm swapctl
173operate on all swap entries in
174.Pa /etc/fstab
175which do not have their
176.Dq noauto
177option set.
178.Pp
179Swap information can be generated using the
180.Xr swapinfo 8
181utility,
182.Nm pstat
183.Fl s ,
184or
185.Nm swapctl
186.Fl l .
187The
188.Nm swapctl
189utility has the following options for listing swap:
190.Bl -tag -width indent
191.It Fl h
192Output values in human-readable form.
193.It Fl g
194Output values in gigabytes.
195.It Fl k
196Output values in kilobytes.
197.It Fl m
198Output values in megabytes.
199.It Fl l
200List the devices making up system swap.
201.It Fl s
202Print a summary line for system swap.
203.Pp
204The
205.Ev BLOCKSIZE
206environment variable is used if not specifically
207overridden.
208512 byte blocks are used by default.
209.El
210.Sh FILES
211.Bl -tag -width ".Pa /dev/{ada,da}?s?b" -compact
212.It Pa /dev/{ada,da}?s?b
213standard paging devices
214.It Pa /dev/md?
215memory disk devices
216.It Pa /etc/fstab
217.Tn ASCII
218file system description table
219.El
220.Sh DIAGNOSTICS
221These utilities may fail for the reasons described in
222.Xr swapon 2 .
223.Sh SEE ALSO
224.Xr swapon 2 ,
225.Xr fstab 5 ,
226.Xr init 8 ,
227.Xr mdconfig 8 ,
228.Xr pstat 8 ,
229.Xr rc 8
230.Sh HISTORY
231The
232.Nm swapon
233utility appeared in
234.Bx 4.0 .
235The
236.Nm swapoff
237and
238.Nm swapctl
239utilities appeared in
240.Fx 5.1 .
241