Skip to content

Instantly share code, notes, and snippets.

@hugojosefson
Created December 10, 2017 22:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hugojosefson/e342a6c68c24027a6a594615793eae5a to your computer and use it in GitHub Desktop.
Save hugojosefson/e342a6c68c24027a6a594615793eae5a to your computer and use it in GitHub Desktop.
Creates swap on debian, for example on a digitalocean vpc.
#!/bin/bash
set -e
touch /var/swap.img
chmod 600 /var/swap.img
dd if=/dev/zero of=/var/swap.img bs=1M count=4096
mkswap /var/swap.img
swapon /var/swap.img
echo "" >> /etc/fstab
echo "/var/swap.img none swap sw 0 0" >> /etc/fstab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment