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 378269e767SBrooks Davis.It vm/vm_param.h 388269e767SBrooks Davis.It vm/swap_pager.h 398269e767SBrooks Davis.In unistd.h 408269e767SBrooks Davis.Ft int 418269e767SBrooks Davis.Fn swapon "const char *special" 428269e767SBrooks Davis.Ft int 438269e767SBrooks Davis.Fn swapoff "const char *special" "u_int flags" 448269e767SBrooks Davis.Sh DESCRIPTION 458269e767SBrooks DavisThe 468269e767SBrooks Davis.Fn swapon 478269e767SBrooks Davissystem call 488269e767SBrooks Davismakes the block device 498269e767SBrooks Davis.Fa special 508269e767SBrooks Davisavailable to the system for 518269e767SBrooks Davisallocation for paging and swapping. 528269e767SBrooks DavisThe names of potentially 538269e767SBrooks Davisavailable devices are known to the system and defined at system 548269e767SBrooks Davisconfiguration time. 558269e767SBrooks DavisThe size of the swap area on 568269e767SBrooks Davis.Fa special 578269e767SBrooks Davisis calculated at the time the device is first made available 588269e767SBrooks Davisfor swapping. 598269e767SBrooks Davis.Pp 608269e767SBrooks DavisThe 618269e767SBrooks Davis.Fn swapoff 628269e767SBrooks Davissystem call disables paging and swapping on the given device. 638269e767SBrooks DavisAll associated swap metadata are deallocated, and the device 648269e767SBrooks Davisis made available for other purposes. 658269e767SBrooks Davis.Pp 668269e767SBrooks DavisThe 678269e767SBrooks Davis.Fa special 688269e767SBrooks Davisargument points to the name of the device or file used for swapping. 698269e767SBrooks Davis.The 708269e767SBrooks Davis.Va flags 718269e767SBrooks Davisargument takes the following flags: 728269e767SBrooks Davis.Bl -tag -width SWAPOFF_FORCE 738269e767SBrooks Davis.It Dv SWAPOFF_FORCE 748269e767SBrooks DavisOverrides a very conservative check that prevents swapoff 758269e767SBrooks Davisif the total amount of free memory and remaining swap 768269e767SBrooks Davisdevices space might be unsufficient for the system to continue 778269e767SBrooks Davisoperating. 788269e767SBrooks Davis.El 798269e767SBrooks Davis.Sh RETURN VALUES 808269e767SBrooks DavisIf an error has occurred, a value of -1 is returned and 818269e767SBrooks Davis.Va errno 828269e767SBrooks Davisis set to indicate the error. 838269e767SBrooks Davis.Sh ERRORS 848269e767SBrooks DavisBoth 858269e767SBrooks Davis.Fn swapon 868269e767SBrooks Davisand 878269e767SBrooks Davis.Fn swapoff 888269e767SBrooks Daviscan fail if: 898269e767SBrooks Davis.Bl -tag -width Er 908269e767SBrooks Davis.It Bq Er ENOTDIR 918269e767SBrooks DavisA component of the path prefix is not a directory. 928269e767SBrooks Davis.It Bq Er ENAMETOOLONG 938269e767SBrooks DavisA component of a pathname exceeded 255 characters, 948269e767SBrooks Davisor an entire path name exceeded 1023 characters. 958269e767SBrooks Davis.It Bq Er ENOENT 968269e767SBrooks DavisThe named device does not exist. 978269e767SBrooks Davis.It Bq Er EACCES 988269e767SBrooks DavisSearch permission is denied for a component of the path prefix. 998269e767SBrooks Davis.It Bq Er ELOOP 1008269e767SBrooks DavisToo many symbolic links were encountered in translating the pathname. 1018269e767SBrooks Davis.It Bq Er EPERM 1028269e767SBrooks DavisThe caller is not the super-user. 1038269e767SBrooks Davis.It Bq Er EFAULT 1048269e767SBrooks DavisThe 1058269e767SBrooks Davis.Fa special 1068269e767SBrooks Davisargument 1078269e767SBrooks Davispoints outside the process's allocated address space. 1088269e767SBrooks Davis.El 1098269e767SBrooks Davis.Pp 1108269e767SBrooks DavisAdditionally, 1118269e767SBrooks Davis.Fn swapon 1128269e767SBrooks Daviscan fail for the following reasons: 1138269e767SBrooks Davis.Bl -tag -width Er 1148269e767SBrooks Davis.It Bq Er ENOTBLK 1158269e767SBrooks DavisThe 1168269e767SBrooks Davis.Fa special 1178269e767SBrooks Davisargument 1188269e767SBrooks Davisis not a block device. 1198269e767SBrooks Davis.It Bq Er EBUSY 1208269e767SBrooks DavisThe device specified by 1218269e767SBrooks Davis.Fa special 1228269e767SBrooks Davishas already 1238269e767SBrooks Davisbeen made available for swapping 1248269e767SBrooks Davis.It Bq Er ENXIO 1258269e767SBrooks DavisThe major device number of 1268269e767SBrooks Davis.Fa special 1278269e767SBrooks Davisis out of range (this indicates no device driver exists 1288269e767SBrooks Davisfor the associated hardware). 1298269e767SBrooks Davis.It Bq Er EIO 1308269e767SBrooks DavisAn I/O error occurred while opening the swap device. 1318269e767SBrooks Davis.It Bq Er EINTEGRITY 1328269e767SBrooks DavisCorrupted data was detected while reading from the file system to open the 1338269e767SBrooks Davisswap device. 1348269e767SBrooks Davis.El 1358269e767SBrooks Davis.Pp 1368269e767SBrooks DavisLastly, 1378269e767SBrooks Davis.Fn swapoff 1388269e767SBrooks Daviscan fail if: 1398269e767SBrooks Davis.Bl -tag -width Er 1408269e767SBrooks Davis.It Bq Er EINVAL 1418269e767SBrooks DavisThe system is not currently swapping to 1428269e767SBrooks Davis.Fa special . 1438269e767SBrooks Davis.It Bq Er ENOMEM 1448269e767SBrooks DavisNot enough virtual memory is available to safely disable 1458269e767SBrooks Davispaging and swapping to the given device. 1468269e767SBrooks Davis.El 1478269e767SBrooks Davis.Sh SEE ALSO 1488269e767SBrooks Davis.Xr config 8 , 1498269e767SBrooks Davis.Xr swapon 8 , 1508269e767SBrooks Davis.Xr sysctl 8 1518269e767SBrooks Davis.Sh HISTORY 1528269e767SBrooks DavisThe 1538269e767SBrooks Davis.Fn swapon 1548269e767SBrooks Davissystem call appeared in 1558269e767SBrooks Davis.Bx 4.0 . 1568269e767SBrooks DavisThe 1578269e767SBrooks Davis.Fn swapoff 1588269e767SBrooks Davissystem call appeared in 1598269e767SBrooks Davis.Fx 5.1 . 160