]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/swapon.2
zfs: merge openzfs/zfs@2e2a46e0a
[FreeBSD/FreeBSD.git] / lib / libc / sys / swapon.2
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.2    8.1 (Berkeley) 6/4/93
29 .\"
30 .Dd December 8, 2021
31 .Dt SWAPON 2
32 .Os
33 .Sh NAME
34 .Nm swapon , swapoff
35 .Nd control devices for interleaved paging/swapping
36 .Sh LIBRARY
37 .Lb libc
38 .Sh SYNOPSIS
39 .It vm/vm_param.h
40 .It vm/swap_pager.h
41 .In unistd.h
42 .Ft int
43 .Fn swapon "const char *special"
44 .Ft int
45 .Fn swapoff "const char *special" "u_int flags"
46 .Sh DESCRIPTION
47 The
48 .Fn swapon
49 system call
50 makes the block device
51 .Fa special
52 available to the system for
53 allocation for paging and swapping.
54 The names of potentially
55 available devices are known to the system and defined at system
56 configuration time.
57 The size of the swap area on
58 .Fa special
59 is calculated at the time the device is first made available
60 for swapping.
61 .Pp
62 The
63 .Fn swapoff
64 system call disables paging and swapping on the given device.
65 All associated swap metadata are deallocated, and the device
66 is made available for other purposes.
67 .Pp
68 The
69 .Fa special
70 argument points to the name of the device or file used for swapping.
71 .The
72 .Va flags
73 argument takes the following flags:
74 .Bl -tag -width SWAPOFF_FORCE
75 .It Dv SWAPOFF_FORCE
76 Overrides a very conservative check that prevents swapoff
77 if the total amount of free memory and remaining swap
78 devices space might be unsufficient for the system to continue
79 operating.
80 .El
81 .Sh RETURN VALUES
82 If an error has occurred, a value of -1 is returned and
83 .Va errno
84 is set to indicate the error.
85 .Sh ERRORS
86 Both
87 .Fn swapon
88 and
89 .Fn swapoff
90 can fail if:
91 .Bl -tag -width Er
92 .It Bq Er ENOTDIR
93 A component of the path prefix is not a directory.
94 .It Bq Er ENAMETOOLONG
95 A component of a pathname exceeded 255 characters,
96 or an entire path name exceeded 1023 characters.
97 .It Bq Er ENOENT
98 The named device does not exist.
99 .It Bq Er EACCES
100 Search permission is denied for a component of the path prefix.
101 .It Bq Er ELOOP
102 Too many symbolic links were encountered in translating the pathname.
103 .It Bq Er EPERM
104 The caller is not the super-user.
105 .It Bq Er EFAULT
106 The
107 .Fa special
108 argument
109 points outside the process's allocated address space.
110 .El
111 .Pp
112 Additionally,
113 .Fn swapon
114 can fail for the following reasons:
115 .Bl -tag -width Er
116 .It Bq Er ENOTBLK
117 The
118 .Fa special
119 argument
120 is not a block device.
121 .It Bq Er EBUSY
122 The device specified by
123 .Fa special
124 has already
125 been made available for swapping
126 .It Bq Er ENXIO
127 The major device number of
128 .Fa special
129 is out of range (this indicates no device driver exists
130 for the associated hardware).
131 .It Bq Er EIO
132 An I/O error occurred while opening the swap device.
133 .It Bq Er EINTEGRITY
134 Corrupted data was detected while reading from the file system to open the
135 swap device.
136 .El
137 .Pp
138 Lastly,
139 .Fn swapoff
140 can fail if:
141 .Bl -tag -width Er
142 .It Bq Er EINVAL
143 The system is not currently swapping to
144 .Fa special .
145 .It Bq Er ENOMEM
146 Not enough virtual memory is available to safely disable
147 paging and swapping to the given device.
148 .El
149 .Sh SEE ALSO
150 .Xr config 8 ,
151 .Xr swapon 8 ,
152 .Xr sysctl 8
153 .Sh HISTORY
154 The
155 .Fn swapon
156 system call appeared in
157 .Bx 4.0 .
158 The
159 .Fn swapoff
160 system call appeared in
161 .Fx 5.1 .