Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mount a VirtualBox Virtual Disk Image (VDI) on a Mac using hdiutil
#!/bin/sh
TEMP="$1.$$.img"
trap "rm -f $TEMP 2>/dev/null" 1 2 3 11 15
offset=`hexdump -s 0x158 -n 4 "$1" | head -1 | awk '{print $5 $4 $3 $2}'`
offset512=`echo "obase=16; ibase=16; $offset / 200" | bc`
ln "$1" "$TEMP"
hdiutil attach "$TEMP" -nomount -section "0x$offset512"
rm -f "$TEMP"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment