Swap File

From VSI OpenVMS Wiki
Jump to: navigation, search

A swap file is a system file used for swapping: moving the working set of the currently executing process out of memory. By default, the swap file is SYS$SYSTEM:SWAPFILE.SYS, but you can create additional swap files (253 is the limit for the total number of swap and page files). The default swap file is installed automatically; additional swap files or swap files in locations other than SYS$SYSTEM:SWAPFILE.SYS need to be explicitly installed in SYPAGSWAPFILES.COM.

Displaying Swap File Size

The size of the swap files can be displayed with SHOW MEMORY/FILES.

Calculating Swap File Size

AUTOGEN calculates an appropriate size for your swap file space automatically. To manually calculate the size for swap file space, use the following formula:

size-in-blocks (total for all swap files on the system) 
= MAXPROCESSCNT * average WSQUOTA for processes running on this system

For VAX, WSQUOTA should be in pages and for Alpha, in pagelets.

Startup Command Procedures

Page and swap files other than SYS$SYSTEM:PAGEFILE.SYS and SYS$SYSTEM:SWAPFILE.SYS must be reinstalled each time the system boots. You can do this by adding the commands to install the files to the startup command procedure SYS$MANAGER:SYPAGSWPFILES.COM. The template file SYS$MANAGER:SYPAGSWPFILES.TEMPLATE includes comments that help explain how this file is used.

Modifying Swap File Settings

There are three ways you can change specifications and sizes of your swap file(s): AUTOGEN (recommended), SWAPFILES.COM (only valid for the primary swap file), and SYSGEN.

AUTOGEN

Use the following syntax in MODPARAMS.DAT:

For the total size of all swap files:

  • SWAPFILE = n (0 if you don't want to change the size of the swapfile; otherwise AUTOGEN may adjust the value)

For the primary swap file:

  • ADD_SWAPFILE = n increases the size of the file by n
  • MAX_SWAPFILE = n sets the maximum size of the file to n; AUTOGEN may make adjustments but will not set the size to more than n
  • MIN_SWAPFILE = n sets the minimum size of the file to n; AUTOGEN may make adjustments but will not set the size to less than n

For additional swap files:

  • SWAPFILEn_NAME = sets the file specification for swapfile n (where n is 2 for secondary, 3 for tertiary, etc)
  • SWAPFILEn_SIZE = m sets the size of swapfile n to m
  • ADD_SWAPFILEn_SIZE = m increases the size of swapfile n by m
  • MAX_SWAPFILEn_SIZE = m sets the maximum size of swapfile n to m
  • MIN_SWAPFILEn_SIZE = m sets the minimum size of swapfile n to m

SWAPFILES.COM

SYS$UPDATE:SWAPFILES.COM is a menu-driven command procedure that lets you change the size of primary system, swap and dump files. It displays their sizes and the amount of space remaining on the system disk first and then lets you specify new values for them. Note that if you make modifications to swap files using SWAPFILES.COM, AUTOGEN may make modifications to them the next time it runs, so it is recommended to update MODPARAMS.DAT with the new sizes of the files.

SYSGEN

You can create and install swap files with the following SYSGEN commands:

CREATE file-spec/SIZE=block-count 
INSTALL file-spec/SWAP

Note that if the file is not SYS$SYSTEM:SWAPFILE.SYS, you will need to install it every time the system boots, so add that INSTALL command to SYPAGSWAPFILES.COM.

Installing Swap Files

The default swap file is installed automatically; additional swap files or swap files in locations other than SYS$SYSTEM:SWAPFILE.SYS need to be explicitly installed in SYPAGSWAPFILES.COM. Swap files are installed with the SYSGEN INSTALL command:

SYSGEN> INSTALL device:filespec /SWAPFILE

Note that is they reside on a device other than the system disk, that device needs to be mounted before the files are installed.

Deleting Swap Files

If you remove a system page, swap, or dump file, do not simply delete the file. The disk might become corrupted if you continue to use the system after you delete the files. Do the following:

  1. Rename the swap file.
  2. Reboot the system.
  3. Delete the renamed file.

See also