700-show-hd-tree
#!/bin/bash
#
# List Disk Snapshot Hierarchy
#
if [ "$UID" -eq 0 ]
  then echo "This script should NOT be run as root."
  exit 1
fi
#
if [ $# -ne 1 ]; then
  echo "Usage: $0 <uuid|filename>"
  exit 1
fi
#
declare -i hddepth=0;
UUID_OR_FILE="$1"
DISK_UUID=`VBoxManage showhdinfo $UUID_OR_FILE|grep "^UUID:"|cut -d":" -f2-|sed 's/[ ]*//'`
DISK_FILE=`VBoxManage showhdinfo $DISK_UUID|grep "^Location:"|cut -d":" -f2-|sed 's/[ ]*//'`
function listuuids {
    let hddepth=$hddepth+1;
    DISK_UUID=${1}
    CHID_UUIDS=`VBoxManage showhdinfo "${DISK_UUID}"|grep -A500 -m1 -e 'Child UUIDs:'|cut -b17-`
    for uuid in $CHID_UUIDS
    do
        for ((i=0; $i < $hddepth; i++))
        do
            let depthit=$hddepth-$i;
            if [ $depthit -eq 1 ]; then
                printf " \__ "
            else
                printf "     "
            fi
        done
        printf "$uuid\e[0m\n";
        listuuids "$uuid";
    done
    let hddepth=$hddepth-1;
}
printf "$DISK_UUID <=> [${DISK_FILE}]\e[0m\n";
listuuids "${DISK_UUID}";
unset i hddepth;

QR Code
QR Code scripts:700-show-hd-tree (generated for current page)