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.

Revisions

  1. @pokle pokle revised this gist Mar 1, 2014. 1 changed file with 5 additions and 14 deletions.
    19 changes: 5 additions & 14 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,12 @@
    Assuming you have an EBS instance for the root filesystem, and you want
    to mount your SSDs (on /dev/xvdb and /dev/xvdc) as raid0 every boot/reboot.
    Launch your EC2 EBS instance with two SSDs on the second and third slots (after the root EBS volume), with this in your userdata:

    Remove the last line of /etc/fstab that refers to /dev/xvdb, and unmount your devices if they are mounted.

    #!/usr/bin/env bash

    umount /dev/xvdb
    umount /dev/xvdc

    mdadm isn't installed by default.

    apt-get install mdadm -y

    We're going to mount at /u01

    mkdir /u01

    Create an upstart configuration to re-initialise the raid device on every boot.

    cat > /etc/init/mount-ephermal-ssd.conf <<HERE
    start on virtual-filesystems

    @@ -40,5 +31,5 @@ Create an upstart configuration to re-initialise the raid device on every boot.

    end script
    HERE

    Now just reboot (to test it all works)
    start mount-ephermal-ssd
  2. @pokle pokle revised this gist Feb 28, 2014. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,6 @@
    Assuming you have an EBS instance for the root filesystem, and you want
    to mount your SSDs (on /dev/xvdb and /dev/xvdc) as raid0 every boot/reboot.

    Prep
    ====

    Remove the last line of /etc/fstab that refers to /dev/xvdb, and unmount your devices if they are mounted.

    umount /dev/xvdb
  3. @pokle pokle created this gist Feb 28, 2014.
    47 changes: 47 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    Assuming you have an EBS instance for the root filesystem, and you want
    to mount your SSDs (on /dev/xvdb and /dev/xvdc) as raid0 every boot/reboot.

    Prep
    ====

    Remove the last line of /etc/fstab that refers to /dev/xvdb, and unmount your devices if they are mounted.

    umount /dev/xvdb
    umount /dev/xvdc

    mdadm isn't installed by default.

    apt-get install mdadm -y

    We're going to mount at /u01

    mkdir /u01

    Create an upstart configuration to re-initialise the raid device on every boot.

    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

    Now just reboot (to test it all works)