macOS

Mounting a VHD in macOS

Source: https://serverfault.com/a/1000645

It's now 2020, and these 10-year-old instructions almost worked. Here's what I did to mount an old Backup Image from Windows 7 on my Mojave Mac, based on the accepted answer from Jan Bernlöhr, as well as the script in the question.

infile=vdfuse.c
outfile=vdfuse
incdir="$(pwd)/include"
INSTALL_DIR="/Applications/VirtualBox.app/Contents/MacOS"
CFLAGS="-pipe"
gcc -arch x86_64 "${infile}" \
       "${INSTALL_DIR}"/VBoxDD.dylib \
       "${INSTALL_DIR}"/VBoxDDU.dylib \
       "${INSTALL_DIR}"/VBoxVMM.dylib \
       "${INSTALL_DIR}"/VBoxRT.dylib \
       "${INSTALL_DIR}"/VBoxDD2.dylib \
      -o "${outfile}" \
      -I"${incdir}" -I"/usr/local/include/fuse" \
      -Wl,-rpath,"${INSTALL_DIR}"  \
      -lfuse_ino64  \
      -Wall ${CFLAGS}
  sudo ./vdfuse -tVHD -w -f/Path/To/VHD /Path/To/Mountpoint
  hdiutil attach -imagekey diskimage-class=CRawDiskImage -nomount /Path/To/Mountpoint/PartitionN
  mount -t YourFS /dev/diskK /Path/To/ParitionMountPoint

Miraculously, this works a charm!