The
swapctl program adds, removes, lists and prioritizes swap devices and files for the system. The
swapon program acts the same as the
swapctl program, as if called with the
-a option, except if
swapon itself is called with
-a in which case,
swapon acts as
swapctl with the
-A option.
The following options are available:
-A
This option causes swapctl to read the /etc/fstab file for devices and files with a “sw” or “dp” type, and adds all “sw” type entries as swap devices and sets the last “dp” type entry as the dump device. If no swap devices are configured, swapctl will exit with an error code. If used together with -t auto this option will not read /etc/fstab but query the kernel for all swap partitions on local hard disks.
-a
The
-a option 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
swapon form of this command, the
-a option is treated the same as the
-A option, for backwards compatibility.
-c
The -c option changes the priority of the listed swap device or file.
-D
The
-D option requires that a
dumpdev also be in the argument list. The kernel dump device is set to
dumpdev. The word “none” can be used instead of a
dumpdev to disable the currently set dump device. This change is made via the
swapctl(2) system call. The dump device is used when the system crashes to write a current snapshot of real memory, to be saved later with
savecore(8) at system reboot, and analyzed to determine the problem.
-d
The -d option removes the listed path from the kernel's list of swap devices or files.
-f
Used in combination with the -A command and -t auto flag this option makes swapctl use the first discovered swap device to also become the dump device. The -f option is mutually exclusive with the -o option.
-g
The -g option uses (1024 * 1024 * 1024) byte blocks instead of the default 512 byte.
-k
The -k option uses 1024 byte blocks instead of the default 512 byte.
-l
The -l option lists the current swap devices and files, and their usage statistics.
-m
The -m option uses (1024 * 1024) byte blocks instead of the default 512 byte.
-n
Used with the -A or -U command, the -n option makes swapctl print the action it would take, but not actually change any swap or dump devices.
-o
Similar to the -f flag, this “Dump Only” option makes swapctl find the first swap device and configure it as dump device. No swap device is changed. This option needs to be used in combination with -A -t auto and is mutually exclusive with -f.
-p
The -p option sets the priority of swap devices or files to the priority argument. This works with the -a, -c, and -l options.
-q
Query /etc/fstab, checking for any defined swap or dump devices. If any are found, swapctl returns with an exit status of 0, if none are found the exit status will be 1.
-s
The -s option displays a single line summary of current swap statistics.
-t
This flag modifies the function of the -A and -U options. The -t option allows the type of device to add to be specified. An argument of blk causes all block devices in /etc/fstab to be added. An argument of noblk causes all non-block devices in /etc/fstab to be added. An argument of auto causes all swap partitions on local hard disks to be used. 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.
-U
This option causes swapctl to read the /etc/fstab file for devices and files with a “sw” type, and remove all these entries as swap devices. If no swap devices are unconfigured, swapctl will exit with an error code. If used together with -t auto this option will not read /etc/fstab but unconfigure all local swap partitions.
-z
The -z option displays the current dump device.