Skip to content

Instantly share code, notes, and snippets.

@heysamtexas
Forked from bertrandom/ephemswap
Last active August 29, 2015 14:20
Show Gist options
  • Save heysamtexas/d2a942124d426d7b13b3 to your computer and use it in GitHub Desktop.
Save heysamtexas/d2a942124d426d7b13b3 to your computer and use it in GitHub Desktop.
#!/bin/bash
if swapon -s | grep -q /mnt/swapfile
then
echo "Swapfile already mounted"
else
if [ -e /mnt/swapfile ]
then
echo "Mounting swapfile"
swapon /mnt/swapfile
else
echo "Creating swapfile"
dd if=/dev/zero of=/mnt/swapfile bs=1M count=4096
mkswap /mnt/swapfile
swapon /mnt/swapfile
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment