United States-English |
|
|
HP-UX Reference > Sswapon(1M)HP-UX 11i Version 3: February 2007 |
|
NAMEswapon — enable device or file system for paging SYNOPSISForm 2: Enable paging on specified block devices (for the current boot)/usr/sbin/swapon [-e |-f] [-p priority] [-u] device ... Form 3: Define the primary paging device (for subsequent boots)/usr/sbin/swapon [-e |-f] -s [-S start] [-L length] [-u] device Form 4: Unconfigure a previously set primary paging device (for subsequent boots)/usr/sbin/swapon -R device DESCRIPTIONThe swapon command enables devices or file systems on which paging is to take place. swapon command also configures primary paging device for next boot. (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 system) 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 network 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 option is given (see Form 1 of SYNOPSIS), 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. In Form 2, the -p option enables specific block devices to be used for paging for the current boot. The device arguments must specify block special files. If more than one device is given, any options specified will be applied to all devices. In Form 3, the -s option configures the block device to be used as the primary paging area for subsequent boots. In either Form 2 or Form 3, 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 inadvertently 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 -f with extreme caution! In either Form 2 or Form 3, 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 paging to devices being used by the savecrash command; however, this may overwrite system dump information contained on the device. In Form 4, the -R option unconfigures the block device that was previously defined as the primary paging area for subsequent boots (see -s option). The last two forms of swapon provide methods for enabling file systems for paging. Form 5 is the preferred method. Form 6 is obsolescent and provided only for backward compatibility. The directory name in these forms 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 /paging). All paging files are created within this directory. The optional arguments to the sixth form have the same meaning as the arguments to the options in Form 5. Note that, in Form 6, if any of the optional arguments are specified, all must be specified. In Form 5, if more than one directory is given, any options specified will be applied to all directories. After a file system has been enabled for paging, the optional arguments can be modified by subsequent swapon commands. Optionsswapon recognizes the following options and arguments:
RETURN VALUEswapon returns one of the following values:
EXAMPLESThe first two examples enable paging to the file system containing the /paging directory. The maximum number of file system blocks available to the paging 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 paging system defaults to 0 in the first example, and is set to 0 in the second example. On a file system with the default 8kB block size, these examples allocate approximately 40MB of file system paging. /usr/sbin/swapon -l 5000 -r 10000 -p 2 /paging /usr/sbin/swapon /paging 0 5000 10000 2 This example enables paging to two block devices and sets the priority of both devices to 0. /usr/sbin/swapon -p 0 /dev/dsk/c10t0d0 /dev/dsk/c13t0d0 This example enables paging to a block device, using the space after the end of the file system for paging and letting the priority default to 1. /usr/sbin/swapon -e /dev/dsk/c4t0d0 This example enables paging to a block device, forcing paging even if a file system exists on the device. /usr/sbin/swapon -f /dev/dsk/c12t0d0 This example defines the primary paging device for the next boot, using the space after the end of the file system to the end of the device for paging. /usr/sbin/swapon -s -e /dev/disk/disk10 This example defines the primary paging device for the next boot, using 8192Kb of the device for paging, starting 1024Kb from the start of the device. /usr/sbin/swapon -s -S 1024 -L 8192 /dev/disk/disk10 WARNINGSOn systems running VxVM 3.5, the swap volumes to be configured for system crash dumps should be created with the usage type as swap during the creation of the swap volume. Not doing so will cause dump corruption. You could use the -U option of vxassist(1M) to do the same. Once file system blocks have been allocated for paging space, the file system cannot be unmounted unless the system is rebooted. If any paging area becomes unavailable while the system is running, for example if a network failure occurs while paging to a remote system, the system will immediately halt. 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)). When using the -l and -r options, the reserve space specified by the -r option takes precedence over the -l option. Thus, if:
the following relationships hold:
FILES
SEE ALSOkctune(1M), savecrash(1M), swapinfo(1M), vxassist(1M), swapctl(2), swapon(2), fstab(4), swchunk(5). |
Printable version | ||
|