Skip to content

Instantly share code, notes, and snippets.

@shaon
Forked from tgerla/gist:4543228
Created April 10, 2013 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaon/5350746 to your computer and use it in GitHub Desktop.
Save shaon/5350746 to your computer and use it in GitHub Desktop.
attach_volume () {
volId=$1
grep vd[a-z]$ /proc/partitions | awk "{print \$4;}" > /tmp/before
sleep 2
# attach the volume
echo "Attaching $volId to $instanceId"
euca-attach-volume -i $instanceId $volId -d /dev/vdc
sleep 5
# detect which device the volume is attached to
grep vd[a-z]$ /proc/partitions | awk "{print \$4;}" > /tmp/after
NEWDEV=$(diff -C0 /tmp/before /tmp/after | grep ^+ | awk "{print \$2;}")
if [ ! $NEWDEV ]; then
echo "Can't detect newly-attached device--quitting."
exit 1
fi
rm -f /tmp/before /tmp/after
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment