PDA

View Full Version : [Solved] How to verify SWAP & enable it on Linux if not used



Fli
03-15-2018, 10:26 AM
How to verify SWAP & enable it on Linux if not used?

Verify by:

swapon --show

If it do not list anything, then enable it.

I think i was successful when running following two commands to enable swap:

Create swap file and activate swapping on it (replace 512M by your desired swap size or 2G to set 2gigabytes swap. You need to have that much free disk space, usually is recommended swap is half of the physical memory RAM):

sudo fallocate -l 512M /swapfile;sudo chmod 600 /swapfile;sudo mkswap /swapfile;sudo swapon /swapfile;free -mht

Activate swapping at boot:

echo "/swapfile none swap sw 0 0" >> /etc/fstab