Skip to content

Instantly share code, notes, and snippets.

@nkrumm
Forked from rcoup/ephemeral-setup.sh
Last active January 2, 2016 20:59
Show Gist options
  • Save nkrumm/8360544 to your computer and use it in GitHub Desktop.
Save nkrumm/8360544 to your computer and use it in GitHub Desktop.
# On EC2, /mnt is usually already on
mounted=$(mount | grep /mnt | wc -l)
if [ $mounted -eq 1 ]; then
umount -l /mnt
fi
# Install mdadm unattended
DEBIAN_FRONTEND=noninteractive apt-get -y install mdadm
# Create a RAID0 volume, don't ask for permission (--run)
mdadm --create /dev/md0 --level 0 --raid-devices=2 --run /dev/xvdb1 /dev/xvdc1
sleep 5
# Wait for volume to be finished (RAID0 does not take long...)
while [[ `sudo mdadm --detail /dev/md0 | grep 'Rebuild Status'` != '' ]]; do
sleep 10
done
# Increase the read-ahead (optional)
# blockdev --setra 65536 /dev/md0
# Create the XFS filesystem, ignore errors tied to ext3 already being there
# mkfs.xfs -f -d su=256k,sw=4 /dev/md0
# mount -t xfs /dev/md0 /mnt
# Or for EXT4:
mkfs.ext4 /dev/md0
mount /dev/md0 /mnt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment