Created
May 13, 2015 01:55
-
-
Save matoken/ad55c297f62b2789eb97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
swapfile='/var/swap' | |
backupfile="$swapfile-`/bin/date +%Y%m%d-%H%M%S-$$`" | |
blocksize='1G' | |
count='1024' | |
if [ $UID -ne "0" ] ; then | |
echo "please re-run as root via sudo." | |
exit 1 | |
fi | |
if [ -e $swapfile ] | |
then | |
echo "File exist( $swapfile )." | |
exit 1 | |
fi | |
echo "creating a swap file." | |
echo "Please wait requires some time..." | |
umask 077 | |
dd if=/dev/zero of=$swapfile bs=1M count=1024 | |
echo "mkswap" | |
mkswap -c /var/swap | |
echo "backup $swapfile $backupfile" | |
cp -p $swapfile $backupfile | |
echo "$swapfile swap swap 0 0" >> /etc/fstab | |
echo "swapon" | |
swapon -a | |
swapon -s | |
echo "Done." | |
exit | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment