enable swap ubuntu

By December 12, 2017Linux

Easily enable swap on Ubuntu 16.04 with this easy to use one-liner.

sudo fallocate -l 16G /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 
echo "Swap enabled" 

Leave a Reply