Add swap space for Linux
Reference document:
If you use a server with smaller memory, you can add a swap space for it.
- execute
sudo swapon --show
, if there already exist swap file, you need delete it as following:1 2
$ sudo swapoff $swapfile $ sudo rm $swapfile
- sudo dd if=/dev/zero of=$swapfile bs=1M count=8192
- sudo chmod 600 $swapfile
- sudo mkswap $swapfile
- sudo swapon $swapfile
Now you can execute sudo swapon --show
or free -m
to ensure it.
Author Linfeng
LastMod 2023-09-01