How to fix invalid swap

To Nha Notes | Dec. 1, 2022, 11:15 a.m.

Sometime there is the problem that swap file exist, but it doesn't appear when we verify with command `swap -s`.

To fix it, we just re-create like commands

dd if=/dev/zero of=/data/swapfile bs=1G count=64
chmod 600 /data/swapfile
mkswap /data/swapfile
swapon /data/swapfile

To verify re-created wap

swapon -s

Use free command to monitor swap space usage

free -g
free -k
free -m