Skip to content

Instantly share code, notes, and snippets.

@smoser
Created September 16, 2011 21:22
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 smoser/1223189 to your computer and use it in GitHub Desktop.
Save smoser/1223189 to your computer and use it in GitHub Desktop.
cat-bdinfo: script to help running an instance and collecting block-device-mapping data
#!/bin/sh
# this was used in testing of block device mapping bugs, ie:
# http://pad.lv/851145: ephemeral device (local_gb) does not get a filesystem
# http://pad.lv/827598: ephemeral device does not have a filesystem
# http://pad.lv/827590: cloud-init does not mount /mnt
# http://pad.lv/828357: request to add a label to the filesystem for ephemeral devices
#
# Usage:
# set up the following functions
# dorun() { ./cat-bdinfo $* > my-bdinfo; euca-run-instances --user-data-file my-bdinfo --key mykey $*; }
# getout() { euca-get-console-output $1 | sed -n '/START/,/END/ { /^#/d; p }'; }
# dorun --instance-type m1.xsmall ami-00000003 --block-device-mapping /dev/vdb=ephemeral0
# ... wait ...
# getout <instance-id>
cat <<EOF
#!/bin/sh
echo "####### START ######"
echo "args: $*"
EOF
cat <<"EOF"
mkdir -p /tmp/xmytmp
cd /tmp/xmytmp
rm -f *
## ttylinux doesn't have the devices so make them
while read maj min blk name ; do
[ -z "$maj" -o "$maj" = "major" ] && continue
[ -e /dev/$name ] || mknod -m 0660 /dev/$name b $maj $min
done < /proc/partitions
md="http://169.254.169.254/latest/meta-data/"
bdm="$md/block-device-mapping/"
echo "===== metadata ===="
wget "$md" >/dev/null 2>&1
echo "metadata/: $(grep block-device-mapping index.html)"
rm -f index.html
wget "$bdm" >/dev/null 2>&1
mv index.html bdm
for x in $(cat bdm); do
wget "$bdm/$x" >/dev/null 2>&1
echo "$x: $(cat $x)"
rm -f $x;
done
echo "===== /proc/partitions ===="
cat /proc/partitions
echo "===== blkid ===="
blkid
echo "###### END ######"
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment