swapctl, swapon —
system swap management tool
  
    | swapctl | -A[-f|-o] [-n]
      [-ppriority]
      [-tblk|noblk|auto] | 
  
    | swapctl | -U[-n]
      [-tblk|noblk|auto] | 
  
    | swapctl | -a[-ppriority] path | 
  
    | swapctl | -c-ppriority path | 
  
    | swapctl | -l|-s[-k|-m|-g|-h] | 
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 swapctlto 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,swapctlwill exit with an error code.
      If used together with-tauto this option will not read
      /etc/fstab but query the kernel for all swap
      partitions on local hard disks.
- -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
- The -Doption 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 -doption removes the listed
      path from the kernel's list of swap devices or
      files.
- -f
- Used in combination with the -Acommand and-tauto flag this option
      makesswapctluse the first discovered swap device
      to also become the dump device. The-foption is
      mutually exclusive with the-ooption.
- -g
- The -goption uses (1024 * 1024 * 1024) byte
      blocks instead of the default 512 byte.
- -h
- The -hoption uses
      humanize_number(3)
      to display the sizes.
- -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.
- -m
- The -moption uses (1024 * 1024) byte blocks
      instead of the default 512 byte.
- -n
- Used with the -Aor-Ucommand, the-noption makesswapctlprint the action it would take, but not
      actually change any swap or dump devices.
- -o
- Similar to the -fflag, this “Dump
      Only” option makesswapctlfind 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-tauto and is mutually exclusive with-f.
- -p
- The -poption sets the priority of swap devices or
      files to the priority argument. This works with the-a,-c, and-loptions.
- -q
- Query /etc/fstab, checking for any defined swap or
      dump devices. If any are found, swapctlreturns
      with an exit status of 0, if none are found the exit status will be
    1.
- -s
- The -soption displays a single line summary of
      current swap statistics.
- -t
- This flag modifies the function of the -Aand-Uoptions. The-toption
      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 swapctlto 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,swapctlwill
      exit with an error code. If used together with-tauto this option will not read
      /etc/fstab but unconfigure all local swap
      partitions.
- -z
- The -zoption displays the current dump
    device.
The NetBSD swap system allows different swap devices and
  files to be assigned different priorities, to allow the 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.
When parsing the /etc/fstab file for swap devices, the
  following options are recognized:
  - priority=N
- This option sets the priority of the specified swap device to N.
- nfsmntpt=/path
- This option is useful for swapping to NFS files. It specifies the local
      mount point to mount an NFS filesystem. The mount point must exist as a
      directory. Typically, once this mount has succeeded, the file to be used
      for swapping on will be available under this point mount. For example:
    
    
server:/export/swap/client none swap sw,nfsmntpt=/swap
    
 
If the requested operation was successful, theswapctl
  utility exits with status 0. If an error occurred, the exit status is 1.
The -A and -U
    operations (add or remove swap devices listed in
    fstab(5)) return an exit status
    of 2 to report that no suitable swap devices were found.
The -z operation (query dump device) and
    -l (list swap partitions) return an exit status of 1
    if no dump device or swap partition has been configured. If any swap
    partition is available or a dump device is set, the respective query returns
    0.
The swapctl program was first made available in
  NetBSD 1.3. The original
  swapon program, provided for backwards compatibility,
  appeared in 4.0BSD.
Using the automatic swap partition detection done by the
  -A -t
  auto option may be dangereous. Depending on the on-disk
  partitioning scheme used, the type of a partition may not be accurately
  recognizable as a swap partition. The autodetection might recognize and use
  partitions on removable media like USB sticks. An easy way to test the
  autoconfiguration is to use swapctl with the
  -n option.
If no swap information is specified in /etc/fstab, the
  system startup scripts (see rc(8))
  will configure no swap space and your machine will behave very badly if (more
  likely when) it runs out of real memory.
Local and remote swap files cannot be configured until after 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 you configure 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.