[Next] [Previous] [Up] [Top] [Contents]

CHAPTER 5 File System Management

5.5 Adding swap space


You can add additional swap space as partitions or as files. Adding them as partitions minimizes overhead as you access the raw partition. To do this under SunOS 4.1.X you would add an entry to /etc/fstab similar to the following.

/dev/sd1b swap swap rw 0 0

You can make a file suitable for use as swap with the mkfile command found in /usr/etc (SunOS 4.1.X) or /usr/sbin (SunOS 5.X), e.g.:

# mkfile 20m /export/swap/swapfile

Under SunOS 4.1.X you add this to the swap area with the swapon command, i.e.:

# /usr/etc/swapon /export/swap/swapfile

To automatically add this swap space when booting add the above entry to /etc/rc.local.

For SunOS 5.X you would use the swap command with the -a (add) option to add the swapfile, i.e.:

# /usr/sbin/swap -a /export/swap/swapfile

You can make an entry in /etc/vfstab to have this automatically added to the swap space after a reboot.

/usr/swapfile - - swap - no -

To display the available swap space under SunOS 5.X do the following:

# swap -l
swapfile dev swaplo blocks free
swapfs - 0 123776 118600
/dev/dsk/c0t3d0s1 32,25 8 66232 50184
/usr/swapfile - 8 30712 14360

To display the total swap space use swap -s in SunOS 5.X or pstat -s in SunOS 4.X, e.g.:

# swap -s
total: 18780k bytes allocated + 6444k reserved = 25224 used, 30084 available

SunOS 5.X allows you to delete swap space at any time. To do this use:

# swap -d /export/swap/swapfile

When the swap file is no longer in use it will be deleted from the available swap space and will no longer be accessible for swapping.

Swapping to a partition is a little more efficient than swapping to a file, though with the latest OS versions the difference is small. Swap files are convenient to set up, especially if you are only going to use them for a short time period. You can then delete them when the need has expired.


Unix System Administration - 8 AUG 1996
[Next] [Previous] [Up] [Top] [Contents]