Skip to content

Instantly share code, notes, and snippets.

@DamnedFacts
Created May 15, 2019 16:38
Show Gist options
  • Save DamnedFacts/2e1ba1001f6c20ba46f837089b602a0d to your computer and use it in GitHub Desktop.
Save DamnedFacts/2e1ba1001f6c20ba46f837089b602a0d to your computer and use it in GitHub Desktop.
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