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.\" $FreeBSD: src/lib/libc/sys/swapon.2,v 1.6.2.6 2001/12/14 18:34:01 ru Exp $ 30.\" 31.Dd September 7, 2010 32.Dt SWAPON 2 33.Os 34.Sh NAME 35.Nm swapon , swapoff 36.Nd control devices for interleaved paging/swapping 37.Sh LIBRARY 38.Lb libc 39.Sh SYNOPSIS 40.In unistd.h 41.Ft int 42.Fn swapon "const char *special" 43.Ft int 44.Fn swapoff "const char *special" 45.Sh DESCRIPTION 46The 47.Fn swapon 48system call 49makes the block device 50.Fa special 51available to the system for 52allocation for paging and swapping. 53The size of the swap area on 54.Fa special 55is calculated at the time the device is first made available 56for swapping. 57.Pp 58The 59.Fn swapoff 60system call disables paging and swapping on the given device. 61All associated swap metadata are deallocated, and the device 62is made available for other purposes. 63.Sh RETURN VALUES 64If an error has occurred, a value of -1 is returned and 65.Va errno 66is set to indicate the error. 67.Sh ERRORS 68Both 69.Fn swapon 70and 71.Fn swapoff 72can fail if: 73.Bl -tag -width Er 74.It Bq Er ENOTDIR 75A component of the path prefix is not a directory. 76.It Bq Er ENAMETOOLONG 77A component of a pathname exceeded 255 characters, 78or an entire path name exceeded 1023 characters. 79.It Bq Er ENOENT 80The named device does not exist. 81.It Bq Er EACCES 82Search permission is denied for a component of the path prefix. 83.It Bq Er ELOOP 84Too many symbolic links were encountered in translating the pathname. 85.It Bq Er EPERM 86The caller is not the super-user. 87.It Bq Er EFAULT 88The 89.Fa special 90argument 91points outside the process's allocated address space. 92.El 93.Pp 94Additionally, 95.Fn swapon 96can fail for the following reasons: 97.Bl -tag -width Er 98.It Bq Er EINVAL 99The system has reached the boot-time limit on the number of 100swap devices, 101.Va vm.nswapdev . 102.It Bq Er ENOTBLK 103The 104.Fa special 105argument 106is not a block device. 107.It Bq Er EBUSY 108The device specified by 109.Fa special 110has already 111been made available for swapping 112.It Bq Er ENXIO 113The major device number of 114.Fa special 115is out of range (this indicates no device driver exists 116for the associated hardware). 117.It Bq Er EIO 118An I/O error occurred while opening the swap device. 119.El 120.Pp 121Lastly, 122.Fn swapoff 123can fail if: 124.Bl -tag -width Er 125.It Bq Er EINVAL 126The system is not currently swapping to 127.Fa special . 128.It Bq Er ENOMEM 129Not enough virtual memory is available to safely disable 130paging and swapping to the given device. 131.El 132.Sh SEE ALSO 133.Xr swapon 8 , 134.Xr sysctl 8 135.Sh HISTORY 136The 137.Fn swapon 138system call appeared in 139.Bx 4.0 . 140The 141.Fn swapoff 142system call appeared in 143.Fx 5.0 144and was later ported to 145.Dx 2.7 . 146