Currently, I manage no less than 40 virtual servers. One of the most awkward things is that some vendors provide swap memory, while others don't. So, the best way to work around this is to add a swap file into the Linux manually. This is useful when you have a server without space to add a swap partition.
I do the following to have 1 GB of swap. Change the data to fit your needs.
dd if=/dev/zero of=/swapfile bs=1M count=1024 or fallocate -l1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo /swapfile none swap defaults 0 0 >> /etc/fstab
Things to Review (Optional)
- Swapiness, and
- zRam
Enjoy!