Skip to content

Instantly share code, notes, and snippets.

@PEKTOP
Created August 15, 2014 19:57
Show Gist options
  • Save PEKTOP/ac51839fbabe55e51620 to your computer and use it in GitHub Desktop.
Save PEKTOP/ac51839fbabe55e51620 to your computer and use it in GitHub Desktop.
Create SWAP 1Gb
#!/bin/bash
if [ ! -f /swapfile ]; then
sudo fallocate -l 1G /swapfile
echo -e "\e[32mSWAP file created.\e[39m"
else
echo -e "\e[33mSWAP file already exist.\e[39m"
fi
if ! [[ `swapon -s | grep /swapfile` ]]; then
sudo mkswap /swapfile
sudo swapon /swapfile
echo -e "\e[32mSWAP created and enabled!\e[39m"
else
echo -e "\e[31mSWAP already enabled!\e[39m"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment