xref: /freebsd/lib/libsys/swapon.2 (revision 2878d99dfcfbdd7a415a7f31cf95fbd53fc8e581)
18269e767SBrooks Davis.\" Copyright (c) 1980, 1991, 1993
28269e767SBrooks Davis.\"	The Regents of the University of California.  All rights reserved.
38269e767SBrooks Davis.\"
48269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without
58269e767SBrooks Davis.\" modification, are permitted provided that the following conditions
68269e767SBrooks Davis.\" are met:
78269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright
88269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer.
98269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright
108269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer in the
118269e767SBrooks Davis.\"    documentation and/or other materials provided with the distribution.
128269e767SBrooks Davis.\" 3. Neither the name of the University nor the names of its contributors
138269e767SBrooks Davis.\"    may be used to endorse or promote products derived from this software
148269e767SBrooks Davis.\"    without specific prior written permission.
158269e767SBrooks Davis.\"
168269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
178269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
188269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
198269e767SBrooks Davis.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
208269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
218269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
228269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
238269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
248269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
258269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
268269e767SBrooks Davis.\" SUCH DAMAGE.
278269e767SBrooks Davis.\"
288269e767SBrooks Davis.Dd December 8, 2021
298269e767SBrooks Davis.Dt SWAPON 2
308269e767SBrooks Davis.Os
318269e767SBrooks Davis.Sh NAME
328269e767SBrooks Davis.Nm swapon , swapoff
338269e767SBrooks Davis.Nd control devices for interleaved paging/swapping
348269e767SBrooks Davis.Sh LIBRARY
358269e767SBrooks Davis.Lb libc
368269e767SBrooks Davis.Sh SYNOPSIS
3765005636SGraham Percival.In vm/vm_param.h
3865005636SGraham Percival.In vm/swap_pager.h
3965005636SGraham Percival.Pp
408269e767SBrooks Davis.In unistd.h
418269e767SBrooks Davis.Ft int
428269e767SBrooks Davis.Fn swapon "const char *special"
438269e767SBrooks Davis.Ft int
448269e767SBrooks Davis.Fn swapoff "const char *special" "u_int flags"
458269e767SBrooks Davis.Sh DESCRIPTION
468269e767SBrooks DavisThe
478269e767SBrooks Davis.Fn swapon
488269e767SBrooks Davissystem call
498269e767SBrooks Davismakes the block device
508269e767SBrooks Davis.Fa special
518269e767SBrooks Davisavailable to the system for
528269e767SBrooks Davisallocation for paging and swapping.
538269e767SBrooks DavisThe names of potentially
548269e767SBrooks Davisavailable devices are known to the system and defined at system
558269e767SBrooks Davisconfiguration time.
568269e767SBrooks DavisThe size of the swap area on
578269e767SBrooks Davis.Fa special
588269e767SBrooks Davisis calculated at the time the device is first made available
598269e767SBrooks Davisfor swapping.
608269e767SBrooks Davis.Pp
618269e767SBrooks DavisThe
628269e767SBrooks Davis.Fn swapoff
638269e767SBrooks Davissystem call disables paging and swapping on the given device.
648269e767SBrooks DavisAll associated swap metadata are deallocated, and the device
658269e767SBrooks Davisis made available for other purposes.
668269e767SBrooks Davis.Pp
678269e767SBrooks DavisThe
688269e767SBrooks Davis.Fa special
698269e767SBrooks Davisargument points to the name of the device or file used for swapping.
70*2878d99dSGraham PercivalThe
718269e767SBrooks Davis.Va flags
728269e767SBrooks Davisargument takes the following flags:
738269e767SBrooks Davis.Bl -tag -width SWAPOFF_FORCE
748269e767SBrooks Davis.It Dv SWAPOFF_FORCE
758269e767SBrooks DavisOverrides a very conservative check that prevents swapoff
768269e767SBrooks Davisif the total amount of free memory and remaining swap
778269e767SBrooks Davisdevices space might be unsufficient for the system to continue
788269e767SBrooks Davisoperating.
798269e767SBrooks Davis.El
808269e767SBrooks Davis.Sh RETURN VALUES
818269e767SBrooks DavisIf an error has occurred, a value of -1 is returned and
828269e767SBrooks Davis.Va errno
838269e767SBrooks Davisis set to indicate the error.
848269e767SBrooks Davis.Sh ERRORS
858269e767SBrooks DavisBoth
868269e767SBrooks Davis.Fn swapon
878269e767SBrooks Davisand
888269e767SBrooks Davis.Fn swapoff
898269e767SBrooks Daviscan fail if:
908269e767SBrooks Davis.Bl -tag -width Er
918269e767SBrooks Davis.It Bq Er ENOTDIR
928269e767SBrooks DavisA component of the path prefix is not a directory.
938269e767SBrooks Davis.It Bq Er ENAMETOOLONG
948269e767SBrooks DavisA component of a pathname exceeded 255 characters,
958269e767SBrooks Davisor an entire path name exceeded 1023 characters.
968269e767SBrooks Davis.It Bq Er ENOENT
978269e767SBrooks DavisThe named device does not exist.
988269e767SBrooks Davis.It Bq Er EACCES
998269e767SBrooks DavisSearch permission is denied for a component of the path prefix.
1008269e767SBrooks Davis.It Bq Er ELOOP
1018269e767SBrooks DavisToo many symbolic links were encountered in translating the pathname.
1028269e767SBrooks Davis.It Bq Er EPERM
1038269e767SBrooks DavisThe caller is not the super-user.
1048269e767SBrooks Davis.It Bq Er EFAULT
1058269e767SBrooks DavisThe
1068269e767SBrooks Davis.Fa special
1078269e767SBrooks Davisargument
1088269e767SBrooks Davispoints outside the process's allocated address space.
1098269e767SBrooks Davis.El
1108269e767SBrooks Davis.Pp
1118269e767SBrooks DavisAdditionally,
1128269e767SBrooks Davis.Fn swapon
1138269e767SBrooks Daviscan fail for the following reasons:
1148269e767SBrooks Davis.Bl -tag -width Er
1158269e767SBrooks Davis.It Bq Er ENOTBLK
1168269e767SBrooks DavisThe
1178269e767SBrooks Davis.Fa special
1188269e767SBrooks Davisargument
1198269e767SBrooks Davisis not a block device.
1208269e767SBrooks Davis.It Bq Er EBUSY
1218269e767SBrooks DavisThe device specified by
1228269e767SBrooks Davis.Fa special
1238269e767SBrooks Davishas already
1248269e767SBrooks Davisbeen made available for swapping
1258269e767SBrooks Davis.It Bq Er ENXIO
1268269e767SBrooks DavisThe major device number of
1278269e767SBrooks Davis.Fa special
1288269e767SBrooks Davisis out of range (this indicates no device driver exists
1298269e767SBrooks Davisfor the associated hardware).
1308269e767SBrooks Davis.It Bq Er EIO
1318269e767SBrooks DavisAn I/O error occurred while opening the swap device.
1328269e767SBrooks Davis.It Bq Er EINTEGRITY
1338269e767SBrooks DavisCorrupted data was detected while reading from the file system to open the
1348269e767SBrooks Davisswap device.
1358269e767SBrooks Davis.El
1368269e767SBrooks Davis.Pp
1378269e767SBrooks DavisLastly,
1388269e767SBrooks Davis.Fn swapoff
1398269e767SBrooks Daviscan fail if:
1408269e767SBrooks Davis.Bl -tag -width Er
1418269e767SBrooks Davis.It Bq Er EINVAL
1428269e767SBrooks DavisThe system is not currently swapping to
1438269e767SBrooks Davis.Fa special .
1448269e767SBrooks Davis.It Bq Er ENOMEM
1458269e767SBrooks DavisNot enough virtual memory is available to safely disable
1468269e767SBrooks Davispaging and swapping to the given device.
1478269e767SBrooks Davis.El
1488269e767SBrooks Davis.Sh SEE ALSO
1498269e767SBrooks Davis.Xr config 8 ,
1508269e767SBrooks Davis.Xr swapon 8 ,
1518269e767SBrooks Davis.Xr sysctl 8
1528269e767SBrooks Davis.Sh HISTORY
1538269e767SBrooks DavisThe
1548269e767SBrooks Davis.Fn swapon
1558269e767SBrooks Davissystem call appeared in
1568269e767SBrooks Davis.Bx 4.0 .
1578269e767SBrooks DavisThe
1588269e767SBrooks Davis.Fn swapoff
1598269e767SBrooks Davissystem call appeared in
1608269e767SBrooks Davis.Fx 5.1 .
161