Skip to content

Instantly share code, notes, and snippets.

@rberrelleza
Created September 19, 2013 00:08
Show Gist options
  • Save rberrelleza/6617514 to your computer and use it in GitHub Desktop.
Save rberrelleza/6617514 to your computer and use it in GitHub Desktop.
Mount AWS volume on Ubuntu
#!/bin/bash
if [[ -z `fdisk -l | grep /dev/xvdb` ]];then
mkdir -p -m 755 /data
result=$(ec2-create-volume --size 100 --availability-zone \$AVAILABILITY_ZONE --region \$REGION_ID)
ec2-attach-volume --region \$REGION_ID $volume -i \$INSTANCE_ID -d /dev/xvdb
while [[ -z `fdisk -l | grep /dev/xvdb` ]]; do sleep 1; done
mkfs.ext4 /dev/xvdb
echo "/dev/xvdb /data auto noatime 0 0" | tee -a /etc/fstab
reboot
exit 100
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment