# check for swap space swapon -s # check filesystem df -h # create and enabled the swap file (e.g. 512MB) sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k sudo mkswap /swapfile # activate the swap file sudo swapon /swapfile # add swap to filesystem vi /etc/fstab # by pasting the following /swapfile swap swap defaults 0 0 # set ownership and permission chown root:root /swapfile chmod 600 /swapfile # configure swappiness (0-100, 100 = swap often and too soon usually) sysctl vm.swappiness=10 cat /proc/sys/vm/swappiness # (optional) set swappiness on boot vi /etc/sysctl.conf # and set vm.swappiness=10 # note: It may be useful to set your swappiness to 0 to ensure that your VPS operates optimally.