Clear SWAP space on a Linux-based system

Send Us a Sign! (Contact Us!)
Epub Text

There have been times where it has been necessary for UNIX Admins to clear out the [gs swap] space on a Linux system. In order to do this, you must first make sure that you have enough free [gs memory] to hold what is being used by swap.

First we want to see what is currently being used.


Then I run the actual commands that empty the swap:

swapoff -a

...and then:

swapon -a

Then I check what is being used after doing this.



Swapon is used to specify devices on which paging and swapping are to take place. Calls toswapon normally occur in the system multi-user initialization file /etc/rc making all swap devices available, so that the paging and swapping activity is interleaved across several devices and files.


-a - All devices marked as ``swap'' swap devices in /etc/fstab are made available. Devices that are already running as swap are silently skipped.

Swapoff disables swapping on the specified devices and files. When the -a flag is given, swapping is disabled on all known swap devices and files (as found in /proc/swaps or/etc/fstab).




1 thought on “Clear SWAP space on a Linux-based system”

Comments are closed.