Monday, June 04, 2007

Adding and Deleting a Swap File

On rare occasions, there might be a need to increase your system's swap space via a local file(s) on your filesystem. However, this should only be done for a temporary situation. Here is an example on how to set up a 100MB swap file and then delete it.

Get a summary of the VM
# swap -s

Create the swap file
# mkfile 100m /data/myswap

Add the swap
# swap -a /data/myswap

Do a listing of the added swap space
# swap -l

Get a summary of the VM
# swap -s

To remove the file swap space, do the following:
# swap -d /data/myswap
# rm /data/myswap

Verify swap file allocation was removed
# swap -s
# swap -l

No comments: