SWAPON(8)

๐Ÿ“ฆ
version 15.1 ยท 2 versions
, in freebsd 15.1

SWAPON(8) โ€” System Manager's Manual realness: specify devices for paging and swapping ๐Ÿ’…โœจ

๐ŸŒธ NAME ๐ŸŒธ

okay so bestie, this whole page is about swapon, swapoff, and swapctl โ€” the iconic trio that specify devices for paging and swapping. thatโ€™s the name, thatโ€™s the vibe. periodt. ๐Ÿ’–

โœจ SYNOPSIS โœจ

swapon [-F fstab] -aLq | -E file ...
swapoff [-F fstab] -afLq | file ...
swapctl [-AfghklmsU] [-a file ... | -d file ...]

๐Ÿ’… DESCRIPTION ๐Ÿ’…

okay so these three utilities control swap devices in the system. at boot time, all swap entries in /etc/fstab are added automatically when the system goes multi-user. swap devices use a fixed interleave; the maximum number of devices is unlimited. there is no priority mechanism. not me explaining swap and having main character energy ๐Ÿ˜ญโœจ

๐ŸŒŸ swapon โ€” the adder

swapon adds the specified swap devices to the system. like, thatโ€™s her whole job. ๐Ÿซถ

  • -a โ€” adds all swap devices in /etc/fstab, unless their โ€œnoautoโ€ or โ€œlateโ€ option is also set.
  • -L โ€” if specified, swap devices with the โ€œlateโ€ option will be added as well as ones with no option.
  • -q โ€” informational messages will not be written to standard output when a swap device is added.
  • -E file ... โ€” causes each of following devices to receive a BIO_DELETE command. this command marks the deviceโ€™s blocks as unused, except those that might store a disk label. this marking can erase a crash dump. to delay swapon for a device until after savecore has copied the crash dump to another location, use the โ€œlateโ€ option. โš ๏ธ

๐ŸŒˆ swapoff โ€” the remover

swapoff removes the specified swap devices from the system. sheโ€™s taking them out of the group chat. ๐Ÿ’…

  • -a โ€” removes all swap devices in /etc/fstab, unless their โ€œnoautoโ€ option is also set.
  • -L โ€” if specified, only swap devices with the โ€œlateโ€ option will be removed.
  • -q โ€” informational messages will not be written to standard output when a swap device is removed.
  • -f โ€” turns off the very conservative check described below, which could deadlock the system if there is insufficient swap space remaining. ๐Ÿ’€

note that swapoff will fail and refuse to remove a swap device if a very conservative check does not conclude that there is sufficient VM (memory + remaining swap devices) to run the system. the -f option turns off this check, which could deadlock the system if there is insufficient swap space remaining.

the swapoff utility must move swapped pages out of the device being removed which could lead to high system loads for a period of time, depending on how much data has been swapped out to that device. literally a whole moment. ๐Ÿ˜ญ

๐ŸŽ€ options supported by both swapon and swapoff

other options supported by both swapon and swapoff are as follows:

  • -F fstab โ€” specify the fstab file to use (in conjunction with -a).

๐Ÿฆ‹ swapctl โ€” the BSD-familiar one

the swapctl utility exists primarily for those familiar with other BSDs and may be used to add, remove, or list swap devices. note that the -a option is used differently in swapctl and indicates that a specific list of devices should be added. the -d option indicates that a specific list should be removed. the -A and -U options to swapctl operate on all swap entries in /etc/fstab which do not have their โ€œnoautoโ€ option set. iykyk. ๐Ÿฆ‹

  • -a file ... โ€” in swapctl, this means the specific list of devices should be added. yes, itโ€™s different from swapon/swapoff -a, bestie. keep up. ๐Ÿ’–
  • -d file ... โ€” the specific list should be removed.
  • -A โ€” operates on all swap entries in /etc/fstab which do not have their โ€œnoautoโ€ option set.
  • -U โ€” operates on all swap entries in /etc/fstab which do not have their โ€œnoautoโ€ option set.
  • -f โ€” appears in the swapctl synopsis flag bundle (-AfghklmsU); no separate swapctl behavior is described in this page. no inventing tea. ๐Ÿ™ˆ

swap information can be generated using the swapinfo(8) utility, pstat -s, or swapctl -l. the swapctl utility has the following options for listing swap:

  • -h โ€” output values in human-readable form.
  • -g โ€” output values in gigabytes.
  • -k โ€” output values in kilobytes.
  • -m โ€” output values in megabytes.
  • -l โ€” list the devices making up system swap.
  • -s โ€” print a summary line for system swap.

the BLOCKSIZE environment variable is used if not specifically overridden. 512 byte blocks are used by default. yes, thatโ€™s an env var, not a flag, but sheโ€™s part of the lore. ๐ŸŽ€

๐ŸŽ€ FILES ๐ŸŽ€

  • /dev/{ada,da}?s?b โ€” standard paging devices
  • /dev/md? โ€” memory disk devices
  • /etc/fstab โ€” ASCII file system description table

๐Ÿฉบ DIAGNOSTICS ๐Ÿฉบ

these utilities may fail for the reasons described in swapon(2). not a vibe, but informed. ๐Ÿซถ

๐Ÿ”— SEE ALSO ๐Ÿ”—

๐Ÿ•ฐ๏ธ HISTORY ๐Ÿ•ฐ๏ธ

the swapon utility appeared in 4.0BSD. the swapoff and swapctl utilities appeared in FreeBSD 5.1. iconic timeline behavior. ๐Ÿ‘‘

and thatโ€™s the page, bestie โ€” source/version + date energy: Debian, November 29, 2021. mwah ๐Ÿ’‹

๐Ÿ“ฆ where this page comes from
  • freebsd 15.1: base 15.1
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms