Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

swapon(2)

swapoff(2)

init(8)

SWAPON(8)  —  UNIX Programmer’s Manual

NAME

swapon, swapoff − specify additional device for paging and swapping

SYNOPSIS

swapon −a
swapon [ −p priority] [ −n ] [ −F ] name ... 
swapon −l [symfile]
swapoff name

DESCRIPTION

Swapon is used to specify additional areas on which paging and swapping are to take place. An area is usually a block special device, but can also be a regular file on the local machine or via NFS.  The system begins by swapping and paging 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 devices available, so that the paging and swapping activity can be interleaved across several devices. 

The swap allocation strategy uses two parameters to control the allocation of swap space.  Process swap space is allocated from the lowest numbered priority (a value between 0 and 7) first.  If interleave is zero, then only a single area is permitted for this priority and an eight times larger swap area can be handled.  If interleave is non-zero, then allocation within a priority is interleaved between all areas of the same priority.  Up to four swap areas can be interleaved at the same priority.  Priority zero must be interleaved, for kernel internal reasons.  It is not permitted to mix non-interleave and interleave within a priority.  If a priority of -1 is given then the area is allocated automatically in the lowest numbered available priority, so the new area will be used first, considering existing swap areas and the interleave state requested. 

Normally, the −a argument is given, causing all devices marked as type “swap” in /etc/fstab to be made available, with the priority and interleave specified by the mnt_freq, and mnt_passno fields. 

The second form adds only the space from area name to the space available for swap allocation. priority can be specified with the -p option, and the -n option specifies non-interleave.  The -F can be used to avoid the checks against destroying file systems, it should be used with extreme caution. 

The −l form lists the current swap areas, with the number of blocks, priority (0-7), interleave (0-3) or exclusive, reads and writes for each area, with the words permanent for the boot-time swap area, swapoff for an area undergoing swapoff in background, or complete for an area which has completed being swapped off in background. 

If the kernel has been booted from a file other than /vmunix, then that file can be given as symname. 

It is suggested that slow swap devices (such as UFS or NFS files) be used at a lower priority that the primary swap area (which is fixed at priority 4). Though access to these file system files is slow, they do allow additional swap space to be made available on existing systems without re-partitioning the disc. 

A fast block device (for example an external winchester) could either be used at a higher priority than the primary area, or if the kernel is modified (with adb or by rebuilding from the binary kit) the additional area can be interleaved with the primary swap area. 

Swapoff can be used to remove an area from the space available for swap allocation.  It can only do this if none of the swap area is in use (allocated to running processes) at the time. 
 

EXAMPLES

Assuming the kernel has been reconfigured to interleave the primary swap partition, then the following line /etc/fstab would make /dev/st1S available as a swap area when a swapon −a command was executed. 

/dev/st1S      -   swap rw   4 1

This could also be achieved by swapon -p 4 /dev/st1S

DIAGNOSTICS

Swapon −a will print the total amount of swap space available. 

Swapoff may state that the swap area is busy at present, in which case the kernel will attempt to completely free the swap area as a background task. If this succeeds a log message is printed and the swapoff command should be repeated.  The state of a background swapoff can be inspected with swapon -l.  The kernel will only try for about a minute to reclaim space from a swapped-off area, so it may be necessary to repeat the swapoff command more than once. 

SEE ALSO

swapon(2), swapoff(2), init(8)

FILES

/etc/fstab

BUGS

The name is inappropriate since RISC iX does not swap, it only pages. 

Priority zero must be interleaved. 

The priority of the primary swap area is fixed at 4, and the interleave is defined by the variable swap_interleave which can only be changed by adb(1) or editing the file param.c in the kernel binary kit. 

Space from the swap areas may be lost due to "rmap overflow" with this being indicated by messages from the kernel. If this happens, then the swapoff command will not be able to free the swap area. The kernel should be reconfigured with a larger values for NSWAPMAP and/or dmmax to prevent this happening (these values can be changed within the kernel binary kit, again in param.c).  NSWAPMAP defines the size of the table used to store free space in the swap map. Increasing the value of dmmax (default value 0x40) increases the maximum possible size of each fragment stored in the table, and hence increases its total capacity. Increasing the value of NSWAPMAP increases the size of the table.  Too large a value of dmmax is inefficient since it can cause more swap space to be allocated than is actually required by a process, whereas increasing NSWAPMAP increases the amount of kernel memory used to store the free swap space map. 

4th Berkeley Distribution  —  Revision 1.6 of 21/10/90

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026