Skip to content

Instantly share code, notes, and snippets.

@alex2006hw
Created November 11, 2014 00:54
Show Gist options
  • Save alex2006hw/074581c94e1c755ff650 to your computer and use it in GitHub Desktop.
Save alex2006hw/074581c94e1c755ff650 to your computer and use it in GitHub Desktop.
script to partition disk for swap on boot up using /etc/rc.local
# sfdisk -d /dev/xvdb to obtain disk geometry output to use below
#
# Format ephemeral disk into partition for swap on /dev/xvdb2
sfdisk /dev/xvdb <<EOF
unit: sectors
/dev/xvdb1 : start= 2048, size=209715200, Id=83
/dev/xvdb2 : start=209717248, size=629073920, Id=82
/dev/xvdb3 : start= 0, size= 0, Id= 0
/dev/xvdb4 : start= 0, size= 0, Id= 0
EOF
mkswap /dev/xvdb2;swapon -a
# Some apps like to write PID info into /var/run
# change /var/run to support writing as non-root user
[ ! -d /run ] && (/bin/mkdir /run)
chmod 777 /run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment