Skip to content

Instantly share code, notes, and snippets.

@tonydub
Created April 18, 2019 13:28
Show Gist options
  • Save tonydub/724290548ef520ba60d5c96b7f80f963 to your computer and use it in GitHub Desktop.
Save tonydub/724290548ef520ba60d5c96b7f80f963 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
swapsize=2048
grep -q "swapfile" /etc/fstab
if [ $? -ne 0 ]; then
echo 'swapfile not found. Adding swapfile.'
fallocate -l ${swapsize}M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap defaults 0 0' >> /etc/fstab
else
echo 'swapfile found. No changes made.'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment