SWAP(8) Maintenance Commands and Procedures SWAP(8)

swap - swap administrative interface

/usr/sbin/swap -a swapname [swaplow] [swaplen]

/usr/sbin/swap -d swapname [swaplow]

/usr/sbin/swap -l [-h | -k]

/usr/sbin/swap -s [-h]

The swap utility provides a method of adding, deleting, and monitoring the system swap areas used by the memory manager.

The following options are supported:

-a swapname [swaplow] [swaplen]

Add the specified swap area. This option can only be used by the superuser or by one who has assumed the Primary Administrator role. swapname is the name of the swap area or regular file. For example, on system running a UFS root file system, specify a slice, such as /dev/dsk/c0t0d0s1, or a regular file for a swap area. On a system running a ZFS file system, specify a ZFS volume, such as /dev/zvol/dsk/rpool/swap, for a swap area. Using a regular file for swap is not supported on a ZFS file system. In addition, you cannot use the same ZFS volume for both the swap area and a dump device when the system is running a ZFS root file system.

swaplow is the offset in 512-byte blocks into the file where the swap area should begin. swaplen is the desired length of the swap area in 512-byte blocks. The value of swaplen can not be less than 16. For example, if n blocks are specified, then (n-1) blocks would be the actual swap length. swaplen must be at least one page in length. The size of a page of memory can be determined by using the pagesize command. See pagesize(1). Since the first page of a swap file is automatically skipped, and a swap file needs to be at least one page in length, the minimum size should be a multiple of 2 pagesize bytes. The size of a page of memory is machine-dependent.

swaplow + swaplen must be less than or equal to the size of the swap file. If swaplen is not specified, an area will be added starting at swaplow and extending to the end of the designated file. If neither swaplow nor swaplen are specified, the whole file will be used except for the first page. Swap areas are normally added automatically during system startup by the /sbin/swapadd script. This script adds all swap areas which have been specified in the /etc/vfstab file; for the syntax of these specifications, see vfstab(5).

To use an NFS or local file system swapname, you should first create a file using mkfile(8). A local file system swap file can now be added to the running system by just running the swap -a command. For NFS mounted swap files, the server needs to export the file. Do this by performing the following steps:

Add the following line to /etc/dfs/dfstab:

share -F nfs -o \
rw=clientname,root=clientname path-to-swap-file

Run shareall(8).
Have the client add the following line to /etc/vfstab:

server:path-to-swap-file -  local-path-to-swap-file nfs \

--- local-path-to-swap-file -- swap ---

Have the client run mount:

# mount local-path-to-swap-file

The client can then run swap -a to add the swap space:

# swap -a local-path-to-swap-file

-d swapname

Delete the specified swap area. This option can only be used by the super-user. swapname is the name of the swap file: for example, /dev/dsk/c0t0d0s1 or a regular file. swaplow is the offset in 512-byte blocks into the swap area to be deleted. If swaplow is not specified, the area will be deleted starting at the second page. When the command completes, swap blocks can no longer be allocated from this area and all swap blocks previously in use in this swap area have been moved to other swap areas.


All sizes are scaled to a human readable format. Scaling is done by repetitively dividing by 1024.


Write the files sizes in units of 1024 bytes.


List the status of all the swap areas. The output has five columns:


The path name for the swap area.


The major/minor device number in decimal if it is a block special device; zeroes otherwise.


The swaplow value for the area in 512-byte blocks.


The swaplen value for the area in 512-byte blocks.


The number of 512-byte blocks in this area that are not currently allocated.

The list does not include swap space in the form of physical memory because this space is not associated with a particular swap area.

If swap -l is run while swapname is in the process of being deleted (by swap -d), the string INDEL will appear in a sixth column of the swap stats.


Print summary information about total swap space usage and availability:


The total amount of swap space in bytes currently allocated for use as backing store.


The total amount of swap space in bytes not currently allocated, but claimed by memory mappings for possible future use.


The total amount of swap space in bytes that is either allocated or reserved.


The total swap space in bytes that is currently available for future reservation and allocation.

These numbers include swap space from all configured swap areas as listed by the -l option, as well as swap space in the form of physical memory.

A block device up to 2^63 −1 bytes can be fully utilized for swap.

See environ(7) for descriptions of the following environment variables that affect the execution of swap: LC_CTYPE and LC_MESSAGE.

pagesize(1), getpagesize(3C), vfstab(5), attributes(7), largefile(7), mkfile(8), shareall(8)

For information about setting up a swap area with ZFS, see the ZFS Administration Guide.

No check is done to determine if a swap area being added overlaps with an existing file system.

June 13, 2021 OmniOS