Skip to content

Instantly share code, notes, and snippets.

@rwrrll
Created April 4, 2014 11:00
Show Gist options
  • Save rwrrll/9972308 to your computer and use it in GitHub Desktop.
Save rwrrll/9972308 to your computer and use it in GitHub Desktop.
Create swap on EBS Instance Storage
# Check for existing swaps:
swapon -s
# None listed? Then go for it!
# Create ~8GB empty file
sudo dd if=/dev/zero of=/mnt/swapfile bs=1M count=8192
# Lock it down
sudo chown root:root /mnt/swapfile
sudo chmod 600 /mnt/swapfile
# Turn it into a swapfile
sudo mkswap /mnt/swapfile
sudo swapon /mnt/swapfile
# Update system
sudo echo "/mnt/swapfile swap swap defaults 0 0" >> /etc/fstab
swapon -a
# Check it's all good
swapon -s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment