HP-UX Reference (11i v2 03/08) - 1M System Administration Commands N-Z (vol 4)

s
swapon(1M) swapon(1M)
NAME
swapon - enable device or file system for paging
SYNOPSIS
Preferred Forms
/usr/sbin/swapon -a
[-u][-t type ]...
/usr/sbin/swapon
[-e -f][-p
priority ][-u] device ...
/usr/sbin/swapon
[-m min][-l limit ][
-r reserve ][-p priority ] directory ...
Obsolescent Form
/usr/sbin/swapon
directory [min limit reserve priority ]
DESCRIPTION
The
swapon command enables devices or file systems on which paging is to take place. (NOTE: the
term ‘swap’ refers to an obsolete implementation of virtual memory; HP-UX actually implements virtual
memory by way of paging rather than swapping. This command and others retain names derived from
‘swap for historical reasons.)
By enabling a device for paging, the device can be accessed directly (without going through the file sys-
tem) during paging activity. When a file system is enabled for paging, the device(s) on which the file
system resides are accessed indirectly through the file system. There are advantages and disadvantages
to both type of paging. Keep the following tradeoffs in mind when enabling devices or file systems for
paging.
Paging directly to a device is significantly faster than doing so through the file system. However, the
space on the device that is allocated to paging cannot be used for anything else, even if it is not being
actively used for paging.
Paging through a file system, while slower, provides a more efficient use of the space on the device.
Space that is not being used for paging in this case can be used by the file system. Paging across a net-
work to a remote machine is always file system paging.
The system begins by paging on only a single device so that only one disk is required at bootstrap time.
Calls to
swapon normally occur in the system startup script /sbin/init.d/swap_start
making all
paging space available so that the paging 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 the file /etc/fstab to be made available to the paging system. By using the fields in
/etc/fstab (special_file_name or directory ; see fstab(4)), 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 within the file system to be
enabled.
The second form of
swapon enables individual block devices to be used for paging. 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 neither an
-e nor -f option is
specified, swapon fails and an error message is given. This prevents a file system from being inadver-
tently destroyed. To request paging in the space between the end of the file system and the end of the
device, use -e. To force paging to a device containing a file system (destroying the file system), the -f
option can be used. Use this with extreme caution!
In either of the previous forms, an attempt to enable paging to a device will fail and a warning message
will be issued if
swapon determines that the device is being used by the savecrash command to
retrieve system dump information (see savecrash (1M)). The -u option can be used to forcibly enable pag-
ing to devices being used by savecrash; however, this may overwrite system dump information con-
tained on the device.
The last two forms of
swapon provide two different methods for enabling file systems for paging. 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. A directory named
/paging is created at the root of the specified file system (unless the file system’s name ends with /pag-
ing). All paging files are created within this directory. The optional arguments to the fourth form have
the same meaning as the arguments to the options in the third form. Note that, in the fourth form, if any
of the optional arguments are specified, all must be specified. In the third form, if more than one direc-
tory is given, any options specified will be applied to all directories.
Section 1M792 Hewlett-Packard Company 1 HP-UX 11i Version 2: August 2003