Swap is disk space the server uses as overflow when RAM runs low. To add a swap file over SSH:
- Create the file (e.g. 2GB):
sudo fallocate -l 2G /swapfile - Secure it:
sudo chmod 600 /swapfile - Format and enable:
sudo mkswap /swapfilethensudo swapon /swapfile - Make it permanent by adding
/swapfile none swap sw 0 0to/etc/fstab
Verify with free -h or swapon --show. A good starting size is roughly equal to your RAM. Note that OpenVZ-based VPS plans may not allow custom swap, in that case your RAM limit is fixed. On unmanaged plans this is your task; managed customers can open a ticket.