VHD is a nice format for exchanging disks. It doesn't take up a lot of bytes with the empty space of a filesystem. But if you want to access the data without a virtual machine it can be a bit of a pain.
The attached program will expand most VHD files into a sparse image of the disk. You can then do whatever you wish with that, such as:
- Use it with a virtual machine that takes raw images.
- Convert it to a VMDK with qemu-img from the qemu folk. (Note: some people say qemu-img can read VHD format already. It didn't work for me and the man page doesn't mention it.)
- Mount it on your Linux box, though you have to skip some bytes to get over the MBR and down to the first partition. Go look at Creating and using disk images mini-howto | Marc's Realm and find "The dirty way". Basically it boils down to trying all the plausible offsets until you find the right one:for ((i=0 ; $i < 10000 ; i=$i + 1)) ; domount -o loop,offset=$(($i * 512)) image.bootable /mnt && breakdone
- Give it a sound grepping.
Note: I don't support this program or even intend to run it ever again. I converted my data. If you need to convert your data, then enjoy.
anonymous comment, 23 months ago
I successfully started a converted windows vista evaulation vhd
I'm still fighting with the mouse and vnc :)
anonymous comment, 23 months ago
anonymous comment, 23 months ago
anonymous comment, 25 months ago
anonymous comment, 25 months ago
Hello Jim,
This looks like just what the doctor ordered but it failed to compile for me:
Did I do something wrong or do you have any suggestions to help fix it?
Thanks much,
Patrick -> patrickkirchner AT yahoo . com
Current Directory = /tmp/vhd2img
-->make
cc -g -MMD -Wstrict-prototypes -Wall -Werror vhd2img.c -o vhd2img
vhd2img.c:38:38: error: missing terminating ' character
vhd2img.c:59:37: error: missing terminating ' character
vhd2img.c:67:67: error: missing terminating ' character
make: *** [vhd2img] Error 1
This looks like just what the doctor ordered but it failed to compile for me:
Did I do something wrong or do you have any suggestions to help fix it?
Thanks much,
Patrick -> patrickkirchner AT yahoo . com
Current Directory = /tmp/vhd2img
-->make
cc -g -MMD -Wstrict-prototypes -Wall -Werror vhd2img.c -o vhd2img
vhd2img.c:38:38: error: missing terminating ' character
vhd2img.c:59:37: error: missing terminating ' character
vhd2img.c:67:67: error: missing terminating ' character
make: *** [vhd2img] Error 1