This guide is applicable only for KVM based VPSes and dedicated servers, If you wish to increase swap on your OpenVZ based VPS please contact us via a Support ticket from the client area.
Once you've done this, we suggest limiting the use of SWAP as using a lot of SWAP affects the Disk I/O, we suggest using the maximum amount of RAM as possible.
Please click here to know how to limit the SWAP usage and maximize the use of RAM.
The following command creates a 512 MB swap file,
dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
If you're running low on disk space or need a small swap file, create a 128 MB swap file with the following command,
dd if=/dev/zero of=/swapfile1 bs=1024 count=131072
or a 64 MB swap file with the following,
dd if=/dev/zero of=/swapfile1 bs=1024 count=65536
chown root:root /swapfile1
chmod 0600 /swapfile1
We will now use the nano file editor to make changes in the fstab file which will make the swapfile permanent and doesn't turn off after a reboot.
Add the following line at the end of the file.
/swapfile1 swap swap sw 0 0
Save and exit the file.
You can reboot the server to confirm if the Swap is enabled.