Skip to content

Instantly share code, notes, and snippets.

@nnzo
Created March 31, 2020 09:14
Show Gist options
  • Save nnzo/dcc4491e7fe05ba7372c0e2de8617350 to your computer and use it in GitHub Desktop.
Save nnzo/dcc4491e7fe05ba7372c0e2de8617350 to your computer and use it in GitHub Desktop.
Create a swapfile on Linux
echo "Creating your 2GB swapfile..."
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
echo "Swapping on"
sudo swapon /swapfile
echo "Making swapfile permanent"
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
echo "All done! run free -m to view your swapfile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment