swapon(1M)
NAME
swapon − enable additional device or file system for paging and swapping
SYNOPSIS
/etc/swapon -a [-u]
/etc/swapon [-p priority] [-u] [-e |-f] device ...
/etc/swapon [-m min] [-l limit] [-r reserve] [-p priority] directory
/etc/swapon directory [min limit reserve priority]
DESCRIPTION
swapon is used to enable additional devices or file systems on which paging and swapping are to take place. By enabling a device for paging and swapping, the device can be accessed directly (without going through the file system) during paging and swapping activity. A device is accessed indirectly through the file system when a file system is enabled for paging and swapping. There are advantages and disadvantages to both.
Paging or swapping directly to a device is faster than doing so through the file system. However, the space on the device that is allocated to paging and swapping cannot be used for anything else, even if it is not being actively paged or swapped to.
Paging or swapping through the file system, while slower, provides a more efficient use of the space on the device. Space that is not being used for paging and swapping in this case can be used by the file system. Keep these tradeoffs in mind when enabling devices or file systems for paging and swapping.
The system begins by paging and swapping on only a single device so that only one disk is required at bootstrap time. Calls to swapon normally occur in the system multi-user initialization file /etc/rc making all swap space available so that the paging and swapping activity is interleaved across several disks.
Normally, the -a argument is given, causing all devices marked as swap and all file systems marked as swapfs in /etc/checklist to be made available to the swap system. By using the first field in /etc/checklist, (special file name) or (directory), the system determines which block device or file system to use. The special file name specified for each swap entry must specify a block special file. The directory specified for each swapfs entry must specify a directory on the file system to be enabled.
The second form of swapon enables individual block devices to be used for paging and swapping. The device name must specify a block special file. If more than one device is given, any options specified will be applied to all devices. If a file system exists on the specified block device and the -e or -f option (see Options below) is not specified, swapon fails and a warning message is given. This prevents a file system from being inadvertently destroyed. To force paging and swapping to a device containing a file system, the -f option can be used. Use this with extreme caution!
In either of the previous forms, an attempt to enable swapping to device will fail and a warning message will be issued if swapon determines the device is being used by savecore to retrieve system dump information. The -u option can be used to forcibly enable swapping to devices being used by savecore; however this may overwrite system dump information contained on device (see savecore(1M)).
The last two forms of swapon provide two different methods for enabling file systems for paging and swapping. The third form is the preferred method, with the fourth being provided only for backward compatibility. The directory name specifies a directory on the file system that is to be enabled for paging and swapping. The optional arguments to the fourth form have the same meaning as the arguments to the options in the third form and are described below (see Options). Note that in the fourth form, if any of the optional arguments are specified, all must be specified.
In the HP Clustered environment, client nodes can swap locally, swap to another client node acting as a swap server, or swap to the root server. Client nodes swapping locally can enable additional local devices for swapping. Swap resources for clients swapping remotely can be enabled on the root server or on the client node acting as its swap server. Refer to System Administrator manuals for more information on swapping in an HP Clustered environment.
Options
swapon recognizes the following options and arguments:
-a Cause all devices marked as swap and all file systems marked as swapfs in /etc/checklist to be made available to the swap system. The options field in /etc/checklist entries is read by swapon, and must contain elements formatted as follows:
min=min See -m min below for value of min.
lim=limit See -l limit below for value of limit.
res=reserve See -r reserve below for value of reserve.
pri=priority See -p priority below for value of priority.
See checklist(4) for example entry.
-e Use space after end of file system on block device for paging and swapping. This option is not supported on Series 800 only. An error message is returned if a file system is not found on the device or if this option is used on a Series 800 system. This option cannot be used with the -f option. Do not confuse this with swapping to a file system; this option is for use with a disk that has both file system and swap space on it.
-f Normally, if a file system exists on the device to be enabled, swapon fails and outputs a warning message. This option forces the device to be enabled which will destroy the file system on it; use with extreme caution. This option cannot be used with the -e option.
-m min min indicates the number of file system blocks the swap system will initially take from the file system. The default value for min is 0, indicating no swap space is to be allocated initially. Block size is defined by the administrator at the time the file system is created.
-l limit limit specifies the maximum number of blocks the swap system is allowed to take from the disk, provided space is available that is not reserved for exclusive use by the file system. See WARNINGS below. The default value for limit is 0, indicating there is no limit to the amount of file system space the swap system can use. Block size is defined by the administrator at the time the file system is created.
-r reserve reserve specifies the number of file system blocks in addition to the space currently occupied by the file system that are reserved for file system use only, making them unavailable to the swap system. See WARNINGS below. The default value for reserve is 0 indicating that no file system space is reserved for file system use only. Block size is defined by the administrator at the time the file system is created.
-p priority priority indicates the order in which space is taken from the file systems and devices used for swapping. Space is taken from the lower priority systems first. priority can have a value between 0-10 and has a default value of 1.
-u Unlock block device files which are being used by savecore. Normally, swapon will not enable swapping on device if it is being used by savecore to retrieve system dump information. The list of devices in use is maintained in file /etc/savecore.LCK. This option forces device to be enabled which may overwrite any system dump information contained on device. This option should be used with extreme caution, and is not currently supported on Series 300/400/700 machines.
RETURN VALUE
swapon returns one of the following values upon completion:
0 Successful completion.
>0 Error condition occurred. See swapon(2) for more information about error message meanings.
EXAMPLES
The first two examples enable swapping to the file system containing the /swap directory. The maximum number of file system blocks available to the swap system is set to 5000, the number of file system blocks reserved for file system use only is set to 10000, and the priority is set to 2. The number of file system blocks initially taken by the swap system defaults to 0 in the first example, and is set to 0 in the second example. On a file system with an 8K block size, these examples allocate approximately 40 MB of file system swap.
/etc/swapon -l 5000 -r 10000 -p 2 /swap
/etc/swapon /swap 0 5000 10000 2
This example enables swapping to two block devices and sets the priority of both devices to 0.
/etc/swapon -p 0 /dev/dsk/c10d0s0 /dev/dsk/c13d0s0
This example enables swapping to a block device on a Series 300, 400, or 700 system, using the space after the end of the file system for swap and letting the priority default to 1.
/etc/swapon -e /dev/dsk/c1400d0s0
This example enables swapping to a block device, forcing swapping even if a file system exists on the device.
/etc/swapon -f /dev/dsk/c12d0s0
WARNINGS
The file system block size used by the -l, -m, and -r options varies between file systems, and is defined by the system administrator at the time the file system is created. The dumpfs command can be used to determine the block size for a particular file system (see dumpfs(1M)).
The system allocates no fewer file system blocks than the amount specified in min. However, to make the most efficient use of space, more than min blocks might be initially taken from the file system. The actual amount taken will not exceed the number of file system blocks indicated in limit.
Swapping to the file system is usually slower than swapping to a device.
When using the -l and -r options, the reserve space specified by the -r option takes precedence over the -l option. Thus, if:
D = total available disk space R = reserve space specified by the -r option limit = swap space specified by the -l option L = space currently available to the swap system F = space currently occupied by the file system
the following relationships hold:
F + R + limit < D in normal operation
L = 0 if F + R ≥ D
0 ≤ L ≤ limit if F + R + limit ≥ D
DEPENDENCIES
Series 800
The -e option is not supported on Series 800 systems.
Series 300, 400, 700
The -u option is not supported on Series 300, 400, and 700 systems.
FILES
/dev/dsk/c#d#s# Normal paging devices.
/etc/checklist File system table.
/etc/savecore.LCK List of devices being used by savecore.
AUTHOR
swapon was developed by HP and the University of California, Berkeley.
SEE ALSO
savecore(1M), swapon(2), checklist(4).
Hewlett-Packard Company — HP-UX Release 9.0: August 1992