1.\" $NetBSD: swapctl.8,v 1.17 2000/03/05 11:35:22 lukem Exp $ 2.\" 3.\" Copyright (c) 1997 Matthew R. Green 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. The name of the author may not be used to endorse or promote products 15.\" derived from this software without specific prior written permission. 16.\" 17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 24.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" SUCH DAMAGE. 28.\" 29.Dd March 5, 2000 30.Dt SWAPCTL 8 31.Os NetBSD 32.Sh NAME 33.Nm swapctl , 34.Nm swapon 35.Nd system swap management tool 36.Sh SYNOPSIS 37.Nm 38.Fl A 39.Op Fl p Ar priority 40.Op Fl t Ar blk|noblk 41.Nm "" 42.Fl D Ar dumpdev 43.Nm "" 44.Fl U 45.Op Fl t Ar blk|noblk 46.Nm "" 47.Fl a 48.Op Fl p Ar priority 49.Ar path 50.Nm "" 51.Fl c 52.Fl p Ar priority 53.Ar path 54.Nm "" 55.Fl d 56.Ar path 57.Nm "" 58.Fl l | Fl s 59.Op Fl k 60.Nm swapon 61.Fl a | Ar path 62.Nm swapoff 63.Ar path 64.Sh DESCRIPTION 65The 66.Nm 67program adds, removes, 68lists and prioritizes swap devices and files for the system. 69The 70.Nm swapon 71program acts the same as the 72.Nm 73program, as if called with the 74.Fl a 75option, except if 76.Nm swapon 77itself is called with 78.Fl a 79in which case, 80.Nm swapon 81acts as 82.Nm 83with the 84.Fl A 85option. 86.Sh OPTIONS 87The following options are available: 88.Bl -tag -width 123456 89.It Fl A 90This option causes 91.Nm 92to read the 93.Pa /etc/fstab 94file for devices and files with a 95.Dq sw 96and 97.Dq dp 98type, and adds all these entries 99as swap devices, or for a dump device in the case of a 100.Dq dp 101type. If no swap devices are configured, 102.Nm 103will exit with an error code. 104.It Fl D 105The 106.Fl D 107option requires that a 108.Ar dumpdev 109also be in the argument list. The kernel dump device is set to 110.Ar dumpdev . 111This changed is made via the 112.Xr swapctl 2 113system call. The dump device is used when the system crashes 114to write a current snapshot of real memory, to be saved later with 115.Xr savecore 8 116at system reboot, and analyzed to determine the problem. 117.It Fl U 118This option causes 119.Nm 120to read the 121.Pa /etc/fstab 122file for devices and files with a 123.Dq sw 124type, and remove all these entries 125as swap devices. 126If no swap devices are unconfigured, 127.Nm 128will exit with an error code. 129.It Fl a 130The 131.Fl a 132option requires that a 133.Ar path 134also be in the argument list. The 135.Ar path 136is added to the kernel's list of swap devices using the 137.Xr swapctl 2 138system call. When using the 139.Nm swapon 140form of this command, the 141.Fl a 142option is treated the same as the 143.Fl A 144option, for backwards compatibility. 145.It Fl c 146The 147.Fl c 148option changes the priority of the listed swap device or file. 149.It Fl d 150The 151.Fl d 152option removes the listed 153.Ar path 154from the kernel's list of swap devices or files. 155.It Fl l 156The 157.Fl l 158option lists the current swap devices and files, and their usage statistics. 159.It Fl s 160The 161.Fl s 162option displays a single line summary of current swap statistics. 163.It Fl p 164The 165.Fl p 166option sets the priority of swap devices or files to the 167.Ar priority 168argument. This works with the 169.\" .Fl d , 170.Fl a , 171.Fl c 172and 173.Fl l 174options. 175.It Fl k 176The 177.Fl k 178option uses 1024 byte blocks instead of the default 512 byte. 179.It Fl t 180This flag modifies the function of the 181.Fl A 182and 183.Fl U 184options. 185The 186.Fl t 187option allows the type of device to add to be specified. An argument of 188.Ar blk 189causes all block devices in 190.Pa /etc/fstab 191to be added. An argument of 192.Ar noblk 193causes all non-block devices in 194.Pa /etc/fstab 195to be added. This option is useful in early system startup, where swapping 196may be needed before all file systems are available, such as during 197disk checks of large file systems. 198.El 199.Sh SWAP OPTIONS 200When parsing the 201.Pa /etc/fstab 202file for swap devices, the following options are recognized: 203.Pp 204.Bl -tag -width nfsmntpt=/path -compact 205.It priority=N 206This option sets the priority of the specified swap device to N. The 207highest priority is 0, second priority is 1, etc. 208.It nfsmntpt=/path 209This option is useful for swapping to NFS files. It specifies 210the local mount point to mount an NFS filesystem. Typically, once 211this mount has succeeded, the file to be used for swapping on will 212be available under this point mount. For example: 213.Bd -literal 214server:/export/swap/client none swap sw,nfsmntpt=/swap 215.Ed 216.El 217.Sh WARNINGS 218If no swap information is specified in 219.Pa /etc/fstab , 220the system startup scripts (see 221.Xr rc 8 ) 222will configure no swap space and your machine will behave very badly 223if (more likely when) it runs out of real memory. 224.Pp 225Local and remote swap files cannot be configured until after the file 226systems they reside on are mounted read/write. The system startup 227scripts need to 228.Xr fsck 8 229all local file systems before this can happen. This process requires 230substantial amounts of memory on some systems. If you configure no 231local block swap devices on a machine that has local file systems to 232check and rely only on swap files, the machine will have no swap space 233at all during system 234.Xr fsck 8 235and may run out of real memory, causing fsck to abnormally exit and 236startup scripts to fail. 237.Sh HISTORY 238The 239.Nm 240program was first made available in 241.Nx 1.3 . 242The original 243.Nm swapon 244program, provided for backwards compatibility, appeared in 245.Bx 4.0 . 246.Sh AUTHOR 247The 248.Nm 249program was written by Matthew R. Green <mrg@eterna.com.au>. 250.Sh SEE ALSO 251.Xr swapctl 2 , 252.Xr fstab 5 , 253.Xr mount_nfs 8 254