Skip to content

Instantly share code, notes, and snippets.

@d6e
Created August 4, 2019 22:14
Show Gist options
  • Save d6e/c5185df874b3ea17e3ec6507ac26bde2 to your computer and use it in GitHub Desktop.
Save d6e/c5185df874b3ea17e3ec6507ac26bde2 to your computer and use it in GitHub Desktop.
Creates a temporary swap file
#!/bin/bash
SWAPFILENAME=swapfile1
SWAPPATH="/$SWAPFILENAME"
if [ ! -f "$SWAPPATH" ]; then
dd if=/dev/zero of="$SWAPPATH" bs=1024 count=1048576
chown root:root "$SWAPPATH"
chmod 0600 "$SWAPPATH"
mkswap "$SWAPPATH"
fi
swapon "$SWAPPATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment