Mount an VHD on Mac OS X
Solution 1:
Finally I got it working. So in summary here are the steps to perform
- Install macfuse
- Install Virtual Box
- Compile vdfuse as mentioned in the question
Mount the vhd disk
sudo ./vdfuse -tVHD -w -f/Path/To/VHD /Path/To/Mountpoint
Attach the virtual partition blockfiles
hdiutil attach -imagekey diskimage-class=CRawDiskImage -nomount /Path/To/Mountpoint/PartitionN
Mount the virtual partition
mount -t YourFS /dev/diskK /Path/To/ParitionMountPoint
Solution 2:
This worked for me on Mountain Lion. No installation or compilation necessary:
hdiutil attach -readonly -imagekey diskimage-class=CRawDiskImage <Path to .vhd file>
Solution 3:
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.
- Install osxfuse (the successor to macfuse)
- Install VirtualBox
- Download the vdfuse source code (
vdfuse.c
) from https://github.com/Thorsten-Sick/vdfuse (currently at v83 - the original link is pegged to v80). - Download the VirtualBox headers, but you have to get a version from 2012.
I used the following command:
svn co -r '{20120801}' http://www.virtualbox.org/svn/vbox/trunk/include/
- Use the following build instructions, adapted from the question, but with a few small alterations (64-bit build, and newer VirtualBoxes don't seem to have VBoxREM.dylib:
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}
Mount the vhd disk
sudo ./vdfuse -tVHD -w -f/Path/To/VHD /Path/To/Mountpoint
Attach the virtual partition blockfiles
hdiutil attach -imagekey diskimage-class=CRawDiskImage -nomount /Path/To/Mountpoint/PartitionN
Mount the virtual partition
mount -t YourFS /dev/diskK /Path/To/ParitionMountPoint
Miraculously, this works a charm!