summaryrefslogtreecommitdiff
path: root/sbin/swapctl/swapctl.8
blob: 7afb792133184c77df5ad1288e48e20dc1e3e447 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
.\"	$OpenBSD: swapctl.8,v 1.16 2001/08/02 18:37:34 mpech Exp $
.\"	$NetBSD: swapctl.8,v 1.14 1998/05/22 18:27:52 msaitoh Exp $
.\"
.\" Copyright (c) 1997 Matthew R. Green
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. The name of the author may not be used to endorse or promote products
.\"    derived from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd June 12, 1997
.Dt SWAPCTL 8
.Os
.Sh NAME
.Nm swapctl ,
.Nm swapon
.Nd system swap management tool
.Sh SYNOPSIS
.Nm swapctl
.Fl A
.Op Fl p Ar priority
.Op Fl t Ar blk|noblk
.Nm swapctl
.Fl a
.Op Fl p Ar priority
.Ar path
.Nm swapctl
.Fl c
.Fl p Ar priority
.Ar path
.Nm swapctl
.Fl d
.Ar path
.Nm swapctl
.Fl l | Fl s
.Op Fl k
.Nm swapon
.Fl a | Ar path
.Nm swapoff
.Ar path
.Sh DESCRIPTION
The
.Nm
program adds, removes,
lists and prioritizes swap devices and files for the system.
The
.Nm swapon
program acts the same as the
.Nm
program, as if called with the
.Fl a
option, except if
.Nm swapon
itself is called with
.Fl a
in which case,
.Nm swapon
acts as
.Nm
with the
.Fl A
option.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl A
This option causes
.Nm
to read the
.Pa /etc/fstab
file for devices and files with an
.Dq sw
type, and adds all these entries
as swap devices.
If no swap devices are configured,
.Nm
will exit with an error code.
.It Fl a
The
.Fl a
option requires that a
.Ar path
also be in the argument list.
The
.Ar path
is added to the kernel's list of swap devices using the
.Xr swapctl 2
system call.
When using the
.Nm swapon
form of this command, the
.Fl a
option is treated the same as the
.Fl A
option, for backwards compatibility.
.It Fl c
The
.Fl c
option changes the priority of the listed swap device or file.
.It Fl d Ar path
The
.Fl d
option removes the listed
.Ar path
from the kernel's list of swap devices or files.
.It Fl l
The
.Fl l
option lists the current swap devices and files, and their usage statistics.
.It Fl s
The
.Fl s
option displays a single line summary of current swap statistics.
.It Fl p Ar priority
The
.Fl p
option sets the priority of swap devices or files to the
.Ar priority
argument.
This works with the
.\" .Fl d ,
.Fl a ,
.Fl c
and
.Fl l
options.
.It Fl k
The
.Fl k
option uses 1024 byte blocks instead of the default 512 byte.
.It Fl t Ar blk|noblk
This flag modifies the function of the
.Fl A
option.
The
.Fl t
option allows the type of device to add to be specified.
An argument of
.Ar blk
causes all block devices in
.Pa /etc/fstab
to be added.
An argument of
.Ar noblk
causes all non-block devices in
.Pa /etc/fstab
to be added.
This option is useful in early system startup, where swapping
may be needed before all file systems are available, such as during
disk checks of large file systems.
.El
.Sh SWAP OPTIONS
When parsing the
.Pa /etc/fstab
file for swap devices, lines such as the following specify additional swap
devices:

.Pp
.Bd -literal -offset indent -compact
 
/dev/sd1b none swap sw 0 0
.Ed
.Pp
Additional flags include:
.Pp
.Bl -tag -width nfsmntpt=/path -compact
.It priority=N
This option sets the priority of the specified swap device to N.
The highest priority is 0, second priority is 1, etc.
.It nfsmntpt=/path
This option is useful for swapping to NFS files.
It specifies the local mount point to mount an NFS filesystem.
Typically, once
this mount has succeeded, the file to be used for swapping on will
be available under this point mount.
For example:
.Bd -literal
server:/export/swap/client none swap sw,nfsmntpt=/swap
.Ed
.El
.Sh WARNINGS
Local and remote swap files cannot be configured until the file
systems they reside on are mounted read/write.
The system startup scripts need to
.Xr fsck 8
all local file systems before this can happen.
This process requires substantial amounts of memory on some systems.
If you configure no
local block swap devices on a machine that has local file systems to
check and rely only on swap files, the machine will have no swap space
at all during system
.Xr fsck 8
and may run out of real memory, causing fsck to abnormally exit and
startup scripts to fail.
.Sh SEE ALSO
.Xr swapctl 2 ,
.Xr fstab 5 ,
.Xr mount_nfs 8 ,
.Xr vnconfig 8
.Sh HISTORY
The
.Nm
program was originally developed in
.Nx 1.3 .
It was ported to
.Ox 2.6
by Tobias Weingartner.
The original
.Nm swapon
program, provided for backwards compatibility, appeared in
.Bx 4.0 .
.Sh AUTHORS
The
.Nm
program was written by Matthew R. Green <mrg@eterna.com.au>.