Skip to content

Instantly share code, notes, and snippets.

@kstevens715
Created November 6, 2013 20:41
Show Gist options
  • Save kstevens715/7343704 to your computer and use it in GitHub Desktop.
Save kstevens715/7343704 to your computer and use it in GitHub Desktop.
Create swap space of 2GB.
#!/usr/bin/env bash
# Exit on any error (non-zero return code)
set -e
# Create swapfile of 2GB with block size 1MB
/bin/dd if=/dev/zero of=/swapfile bs=1024 count=2097152
# Set up the swap file
/sbin/mkswap /swapfile
# Enable swap file immediately
/sbin/swapon /swapfile
# Enable swap file on every boot
/bin/echo '/swapfile swap swap defaults 0 0' >> /etc/fstab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment