Generally, you would want to have a dedicated partition for swap however, a swap file can also be used. You can follow the steps below to create/increase your swap file on a cPanel server. Please note, you must have root access to perform this action. If you’re unsure if you need to do this, please either consult our support department (if you’re a VeeroTech customer) or your server administrator before performing these steps.
Creating the swap file via ssh:
touch /swapfile
Create a 2GB swap file using the command below:
dd if=/dev/zero of=/swapfile bs=1M count=2048
Make the swap
mkswap /swapfile
Activate the swap file:
swapon /swapfile
Add an entry to the fstab to mount the swap file on boot:
nano /etc/fstab
Once inside of the editor for the fstab, enter the line below at the end of the file:
/swapfile swap swap defaults 0 0
Now, save/close the fstab file & reboot your server. Once rebooted, you should now see the new swap size.

If you have any web hosting questions please feel free to reach out to us. We're happy to help.