swapctl8
System swap management tool
Usage
swapctl -A
[-p
priority]
[{-t
blk | noblk}]
swapctl -a
[-p
priority]
path
swapctl -c
-p
priority
path
swapctl -d
path
swapctl [{[-l] | -s}]
[-k]
swapon {-a | path}
Overview
The 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 swapon itself is called with -a, in which case it acts as swapctl -A.
The options are as follows:
-
-A -
This option causes
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. -
-a -
The
-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 theswaponform of this command, the-aoption is treated the same as the-Aoption, for backwards compatibility. -
-c -
The
-coption changes the priority of the listed swap device or file. -
-d path -
The
-doption removes the listed path from the kernel's list of swap devices or files. -
-k -
The
-koption uses 1024 byte blocks instead of the default 512 byte. -
-l -
The
-loption lists the current swap devices and files, and their usage statistics. -
-p priority -
The
-poption sets the priority of swap devices or files to the priority argument. -
-s -
The
-soption displays a single line summary of current swap statistics. -tblk|noblk-
This flag modifies the function of the
-Aoption. The-toption allows the type of device to add to be specified. An argument ofblkcauses all block devices in /etc/fstab to be added. An argument ofnoblkcauses 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.
Options
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:
- priority=N
-
Swap devices and files may be assigned different priorities, to allow faster resources to be used first. Swap devices at the same priority are used in a round-robin fashion until there is no more space available at this priority, when the next priority level will be used. The default priority is 0, the highest. This value can be any valid integer, with higher values receiving less priority.
- nfsmntpt=/path
-
This option is useful for swapping to NFS files. It specifies an existing directory /path to be used as the local mount point for an NFS file system. Typically, once this mount has succeeded, the file to be used for swapping on will be available under this mount point. For example:
server:/export/swap/client none swap sw,nfsmntpt=/swap
Exit status
The swapctl utility exits 0 on success, and >0 if an error occurs.
Releases
56 releases since OpenBSD 2.6; the text changed 18 times.
- 2.6
- 2.7
- 2.8
- 2.9
- 3.0
- 3.1
- 3.2
- 3.3
- 3.4–3.9
- 4.0–4.1
- 4.2–4.8
- 4.9
- 5.0–5.3
- 5.4–5.8
- 5.9–6.6
- 6.7–6.9
- 7.0–7.5
- 7.6–7.7
- 7.8–8.0
-t until OpenBSD 5.8.