- Joined
- Apr 24, 2016
- Messages
- 424
- Points
- 18
Can you guys tell me what is swap memory? does it help increase RAM for my VPS or dedicated server? what are its main benefits?
SWAP memory is a secondary storage on disk. It was (and it's still) mostly used to avoid running out of memory. On linux, when your RAM usage is too high, if there is a SWAP partition on your disk, your operating system will automatically move some data on it. But the main issue is SWAP is very slow compared to RAM, even on SSD storage. That's why, it's better to avoid using too much SWAP for better performance.Can you guys tell me what is swap memory? does it help increase RAM for my VPS or dedicated server? what are its main benefits?
# Create a swap directory of 1GB
dd if=/dev/zero of=/var/swap bs=1k count=1024k
#Prepare the directory /var/swap to use it as swap
mkswap /var/swap
swapon /var/swap
# mount the swap partition
echo '/var/swap swap swap defaults 0 0' | sudo tee -a /etc/fstab