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