Skip to content

Instantly share code, notes, and snippets.

@mkdynamic
Forked from pokle/gist:9271432
Created May 11, 2014 03:32
Show Gist options
  • Save mkdynamic/fcbbe1a37fa22ce2989d to your computer and use it in GitHub Desktop.
Save mkdynamic/fcbbe1a37fa22ce2989d to your computer and use it in GitHub Desktop.

Launch your EC2 EBS instance with two SSDs on the second and third slots (after the root EBS volume), with this in your userdata:

#!/usr/bin/env bash

umount /dev/xvdb
umount /dev/xvdc
apt-get install mdadm -y
mkdir /u01
cat > /etc/init/mount-ephermal-ssd.conf  <<HERE
start on virtual-filesystems

script
  # Attempt a short circuit mount - one of these works 
  # after a reboot
  mount /dev/md127 /u01 && exit 
  mount /dev/md0 /u01 && exit 

  # It's possible this was a EC2 STOP/START - create everything from scratch
  # Although we specify md0, the actual device may be md127 upon reboot!!!
  yes | mdadm --create --verbose --force /dev/md0 --level=0 --raid-devices=2 /dev/xvdb /dev/xvdc

  # Last chance 
  mount /dev/md127 /u01 && exit  
  mount /dev/md0 /u01 && exit

  # Clean FS
  mkfs.ext4 /dev/md0 
  mount /dev/md127 /u01 && exit
  mount /dev/md0 /u01 && exit

end script
HERE

start mount-ephermal-ssd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment