Linux enable and disable swap
1. Enable Swap
1.1 Check the usage of Swap
total used free shared buff/cache available
Mem: 417 188 21 2 221 229
Swap: 2047 0 2047
1.2 Add Swap file
cd /usr
mkdir swap && cd swap
dd if=/dev/zero of=/usr/swap/swapfile1 bs=1M count=2048
bs=1M means the size of block written is 1M,count=2048 means we created a swap file which is 2048M totally.
1.3 Check the size of swap file created
du -sh /usr/swap/swapfile1
1.4 Make the swap file to be recognized by system
mkswap /usr/swap/swapfile1
1.5 Enable usage of the swap file
swapon /usr/swap/swapfile1
1.6 Edit /etc/fstab
/usr/swap/swapfile1 swap swap defaults 0 0
1.7 Check the swap file mounted successfully
swapon -s
Reference:
[1]:https://timberkito.com/?p=98