Skip to content

Instantly share code, notes, and snippets.

@withinboredom
Last active December 23, 2015 20:19
Show Gist options
  • Save withinboredom/75a589b6aa839731e472 to your computer and use it in GitHub Desktop.
Save withinboredom/75a589b6aa839731e472 to your computer and use it in GitHub Desktop.
Create Attachments
#!/bin/bash
echo "Installing utilities"
aptitude update
aptitude install xfsprogs mdadm
read -n 1
echo "Creating drives"
for x in {1..4}; do
ec2-create-volume -C /home/ubuntu/.aws/cert-BFUJDRVUAIJYVUVJHHUPWS423TEXFAX6.pem -K /home/ubuntu/.aws/pk-BFUJDRVUAIJYVUVJHHUPWS423TEXFAX6.pem --size 128 --region eu-west-1 -z eu-west-1a;
done > /tmp/vols.txt
read -n 1
echo "Attaching drives"
(i=0;
for vol in $(awk '{print $2}' /tmp/vols.txt); do
i=$(( i + 1 ));
ec2-attach-volume $vol -C /home/ubuntu/.aws/cert-BFUJDRVUAIJYVUVJHHUPWS423TEXFAX6.pem -K /home/ubuntu/.aws/pk-BFUJDRVUAIJYVUVJHHUPWS423TEXFAX6.pem --region eu-west-1 -i i-fd695db2 -d /dev/sdh${i};
done)
read -n 1
echo "Creating RAID10 device"
mdadm --create -l10 -n4 /dev/md0 /dev/xvdh*
read -n 1
echo "Formatting Drive"
mkfs.xfs /dev/md0
read -n 1
echo "Mounting drive"
mkdir /mnt/new_var
mount /dev/md0 /mnt/new_var
mv /var/* /mnt/new_var/
umount /mnt/new_var
mount /dev/md0 /var
read -n 1
echo "Storing mount information in fstab"
echo "/dev/md0 /var xfs defaults 0 0" >> /etc/fstab
echo "/var/swapFile none swap sw 0 0" >> /etc/fstab
read -n 1
echo "Creating swap file"
dd if=/dev/zero of=/var/swapFile bs=1024 count=3072k
mkswap /var/swapFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment