swapon(8) — Maintenance
NAME
swapon − Specifies additional file for paging and swapping
SYNOPSIS
/sbin/swapon [-asv] [-p priority] [-l lowsize] [-h highsize] filename
DESCRIPTION
The swapon command is used to specify additional paging files. A paging file can be a block special device. (DEC OSF/1 does not currently support paging and swapping to a regular file. All swapping and paging areas must be block special devices.) The swapon command uses a priority default of 4 for block special devices. Calls to swapon normally occur in the system multiuser state initialization.
To add swap space, you first must specify the swap disk partition in the /etc/fstab file. Then, use the swapon command, specifying the partition.
The swapon command flags can override the partition specifications in the /etc/fstab file.
(Because DEC OSF/1 does not currently support paging and swapping to a regular file, the -p option is not supported.) The -p flag specifies the priority of the paging file. When the kernel looks for a paging file, it pages to the highest priority file that is available. If the file is unavailable, it tries a file of the next highest priority, and so on until it finds a file onto which it can page. (A file becomes unavailable when it has no more space.) Priorities are 0, 1, 2, 3, 4, with 0 being lowest priority, and 4 being highest priority. Multiple paging files can have the same priority. For example, there can be two files installed at priority 4. Files of the same priority are paged out to in a round-robin fashion to balance their usage.
(Because DEC OSF/1 does not currently support paging and swapping to a regular file, the -l and -h options are not supported.) The -l option is used to specify the low water mark. Normally, the -a option is used, causing all files marked as sw (swap files) in the /etc/fstab file to be made available. The -h option is used to specify the high water mark. The operating system will not expand the paging file to be larger than the high water mark. If the paging file grows larger than the low water mark, and then shrinks below the low water mark, the operating system will not make the file smaller than the low water mark. If the low water mark is set to 0, then the paging file will not shrink after paging space is freed. The default value for the low water mark is 20Mbytes; the default value for the high water mark is unlimited.
You can use Logical Storage Manager (LSM) volumes for additional swap space. For high system availability, you can mirror the LSM volumes. The Logical Storage Manager manual describes how to configure an LSM volume as additional swap space.
There are two strategies for swap space allocation: immediate mode and deferred or over-commitment mode. The two strategies differ in the point in time at which swap space is allocated. If immediate mode is used, swap space is allocated when modifiable virtual address space is created. If deferred mode is used, swap space is not allocated until the system needs to write a modified virtual page to swap space. Immediate mode is the default swap space allocation strategy.
Immediate mode is more conservative than deferred mode because each modifiable virtual page is assigned a page of swap space when it is created. If you use the immediate mode of swap space allocation, you must allocate a swap space that is at least as large as the total amount of modifiable virtual address space that will be created on your system. Immediate mode requires significantly more swap space than deferred mode because it guarantees that there will be enough swap space if every modifiable virtual page is modified.
If you use the deferred mode of swap space allocation, you must estimate the total amount of virtual address space that will be both created and modified, and compare that total amount with the size of your system’s physical memory. If this total amount is greater than the size of physical memory, the swap space must be large enough to hold the modified virtual pages that do not fit into your physical memory. If your system’s workload is complex and you are unable to estimate the appropriate amount of swap space by using this mode, you should first use the default amount of swap space and adjust the swap space as needed.
To determine which swap space allocation mode is being used, check for the existence of a soft link named /sbin/swapdefault, which points to the primary swap partition. If the /sbin/swapdefault file exists, the system uses the immediate mode for swap space allocation. To enable the deferred mode, rename or delete this soft link.
If the /sbin/swapdefault file does not exist and you want to use the immediate mode of swap space allocation, become superuser and create the file by using the following command syntax:
ln −s /dev/rzxy /sbin/swapdefault
The x variable specifies the device number for the device that holds the primary swap partition, and the y variable specifies the swap partition. Usually, the swap device number is the same as the boot device number, and the primary swap partition is partition b.
You must reboot the system for the new mode to take effect.
FLAGS
-aInstalls all paging files specified in the /etc/fstab file.
-h highsizeThe high water mark. Currently not supported.
-l lowsizeThe low water mark. Currently not supported.
-p priorityThe priority of the specified paging file. Currently not supported.
-sDisplays swap space utilization. For each swap partition, this flag displays the total amount of allocated swap space, the amount of swap space that is being used, and the amount of free swap space.
-vGenerates verbose output.
NOTES
There is no way to stop paging and swapping on a file. It is therefore not possible to use swap files that can be dismounted during system operation.
The new -p flag replaces earlier versions of the -p flag, which caused the swapon command to designate the paging file as a preferred paging file.
EXAMPLES
The following example shows a swap file entry in an /etc/fstab file:
/dev/rz0b swap2 ufs sw 0 0
The following command adds the /dev/rz0b block device file as swap space:
swapon /dev/rz0b
FILES
/sbin/swapon
Specifies the command path
/etc/fstabSpecifies information about file systems and swap files.
/sbin/swapdefault
Specifies the primary swap partition and indicates that the immediate mode of swap space allocation is being used.
RELATED INFORMATION
Functions: swapon(2)
System Administration