Skip to content

Instantly share code, notes, and snippets.

@bobmeliev
Created November 22, 2013 01:04
Show Gist options
  • Save bobmeliev/7592932 to your computer and use it in GitHub Desktop.
Save bobmeliev/7592932 to your computer and use it in GitHub Desktop.
Bash script for ubuntu to create swap in DigitalOcean droplets.
#!/bin/bash
echo "Creating swap..."
sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k
sudo mkswap /swapfile
sudo swapon /swapfile
sudo echo "/swapfile none swap sw 0 0 " >> /etc/fstab
sudo echo 0 > /proc/sys/vm/swappiness
sudo chown root:root /swapfile
sudo chmod 0600 /swapfile
echo "Swap created."
sudo swapon -s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment