|SWAPCTL(8)||System Manager's Manual||SWAPCTL(8)|
— system swap management tool
swapctl program adds, removes, lists
and prioritizes swap devices and files for the system. The
swapon program acts the same as
swapctl -a, except if
itself is called with
-a, in which case it acts as
The options are as follows:
swapctlto read the /etc/fstab file for devices and files with an “sw” type, and adds all these entries as swap devices. If no swap devices are configured,
swapctlwill exit with an error code.
-aoption requires that a path also be in the argument list. The path is added to the kernel's list of swap devices using the swapctl(2) system call. When using the
swaponform of this command, the
-aoption is treated the same as the
-Aoption, for backwards compatibility.
-coption changes the priority of the listed swap device or file.
-doption removes the listed path from the kernel's list of swap devices or files.
-koption uses 1024 byte blocks instead of the default 512 byte.
-loption lists the current swap devices and files, and their usage statistics.
-poption sets the priority of swap devices or files to the priority argument.
-soption displays a single line summary of current swap statistics.
-toption allows the type of device to add to be specified. An argument of
blkcauses all block devices in /etc/fstab to be added. An argument of
noblkcauses all non-block devices in /etc/fstab to be added. This option is useful in early system startup, where swapping may be needed before all file systems are available, such as during disk checks of large file systems.
Lines such as the following specify swap devices in /etc/fstab:
/dev/sd1b none swap sw d48d0e3fc1c39531.k none swap sw
The initial swap device (root disk, partition b) need not appear in /etc/fstab, though it is not an error for it to do so.
Additional flags include:
server:/export/swap/client none swap sw,nfsmntpt=/swap
swapctl utility exits 0 on
success, and >0 if an error occurs.
swapctl program was originally
developed in NetBSD 1.3. It was ported to
OpenBSD 2.6 by Tobias Weingartner. The original
swapon program, provided for backwards
compatibility, appeared in 4.0BSD.
swapctl program was written by
Matthew R. Green
Local and remote swap files cannot be configured until the file systems they reside on are mounted read/write. The system startup scripts need to fsck(8) all local file systems before this can happen. This process requires substantial amounts of memory on some systems. If one configures no local block swap devices on a machine that has local file systems to check and rely only on swap files, the machine will have no swap space at all during system fsck(8) and may run out of real memory, causing fsck to abnormally exit and startup scripts to fail.
|August 24, 2021||OpenBSD-current|