Skip to content

Instantly share code, notes, and snippets.

@zaherg
Created January 25, 2014 07:31
Show Gist options
  • Save zaherg/8613022 to your computer and use it in GitHub Desktop.
Save zaherg/8613022 to your computer and use it in GitHub Desktop.
create a swap on VPS
sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k && sudo mkswap /swapfile && sudo swapon /swapfile

edit fstab

sudo nano /etc/fstab 

add to fstab

/swapfile       none    swap    sw      0       0 

finish up

echo 0 | sudo tee /proc/sys/vm/swappiness
echo vm.swappiness = 0 | sudo tee -a /etc/sysctl.conf

sudo chown root:root /swapfile 
sudo chmod 0600 /swapfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment