Skip to content

Instantly share code, notes, and snippets.

@jeffgreenca
Created April 27, 2016 21:23
Show Gist options
  • Save jeffgreenca/7c6ed7d85f178540150536cfa73c5641 to your computer and use it in GitHub Desktop.
Save jeffgreenca/7c6ed7d85f178540150536cfa73c5641 to your computer and use it in GitHub Desktop.
Add a swap file Linux
#!/bin/sh
echo "Current Memory Configuration"
free -m
read -p "Continue or ctrl-c? "
echo "Disk Free Space"
df -h
read -p "Make 4GB swap file at /swapfile? Continue or ctrl-c..."
echo "Allocating space..."
fallocate -l 4G /swapfile
echo "Formatting as swap..."
mkswap /swapfile
echo "Enabling swap..."
swapon /swapfile
echo "Result"
swapon -s
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment