08.21.2019
How to add swap on Centos
To make your server can handles big processes or do memory cache. You should add swap on server if you not have to much ram
Make Swap file
$dd if=/dev/zero of=/swap bs=1M count=1024
$chmod 0600 /swap
then begin to mount your swap file
$mkswap /swap
$swapon /swap
To check your swap
$ free -m
Te make swap enable automatically each time reboot
vim /etc/fstab
paste below line into the end of file
/swap swap swap defaults 0 0
Recommended swap size
RAM Size | Swap Size (Without Hibernation) | Swap Size (With Hibernation) |
---|---|---|
256MB | 256MB | 512MB |
512MB | 512MB | 1GB |
1GB | 1GB | 2GB |
2GB | 2GB | 3GB |
3GB | 2GB | 5GB |
4GB | 2GB | 6GB |
6GB | 2GB | 8GB |
8GB | 3GB | 11GB |
12GB | 3GB | 15GB |
16GB | 4GB | 20GB |
24GB | 5GB | 29GB |
32GB | 6GB | 38GB |
64GB | 8GB | 72GB |
128GB | 11GB | 139GB |
Hope this help