How to Check Swap Utilization in Linux

Swap Memory is the virtual memory that is used when the physical (RAM) memory is full. Processes that cannot be handled by the RAM will be handled by the Swap (if any).

The swap can be a file or partition. In the following article, I will discuss about how to add the Swap memory capacity in the form of files if you are experiencing a shortage of Swap Memory, or even if you do not have to Swap Memory at all. The following steps add a Swap File (for example, 1 GB):

1. Create a 1 GB file, and then name the Swap example partitioning
dd if=/dev/zero of=/swap bs=1024 count=1048576

2. Create the file Swap
mkswap /swap

3. Change the permissions and ownership of these Swap files
chown root.root /swap
chmod 0600 /swap

4. Then set the Swap file Memory
swapon /swap

5. Now check the total Swap Memory with your new command [top] or [free-m]
My previous: swap memory
KiB Swap:  3905532 total,        0 used,  3905532 free,

After added 1 GB:
KiB Swap:  4954104 total,        0 used,  4954104 free,

6. To disable the memory Swap file and returns the total capacity of your memory to the Swap of origin, run the command:
swapoff /swap

7. Addition of Swap memory with the steps above are temporary. That is, Swap the Memory you will be back to normal when done reboot. However, you can also create permanent in the following ways:
nano /etc/fstab

Add the following line in fstab
/swap swap swap defaults 0 0

Then Save.
This is how the zoom capacity Swap Memory, as well as how to check SWAP. May be useful.

Click here for Comments