Skip to content

Instantly share code, notes, and snippets.

@yigitozkavci
Created July 19, 2017 07:12
Show Gist options
  • Save yigitozkavci/7ebeef5e29712018875f9f29499c81d8 to your computer and use it in GitHub Desktop.
Save yigitozkavci/7ebeef5e29712018875f9f29499c81d8 to your computer and use it in GitHub Desktop.
Add and configure swap space on ubuntu
SWAP_SIZE="1G" # Generally x1 or x2 of your memory is sufficient
sudo fallocate -l "$SWAP_SIZE" /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
echo 'vm.vfs_cache_pressure=50' | sudo tee -a /etc/sysctl.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment