Browsers

googlebot25.0%
Firefox19.3%
yahoobot14.9%
msnbot11.5%
IE 610.6%
hiding5.7%
Chrome4.8%
Safari3.1%
IE 71.8%
IE 81.8%
Opera0.8%
Konqueror0.4%
jeevesbot0.1%
IE 50.1%
Wordpress0.0%
unknown0.0%
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)) ; do
        mount -o loop,offset=$(($i * 512)) image.bootable /mnt && break
    done
  • 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.

Attachments

vhd2img.tar.gz 4515 bytes
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
the bsod is probably a 7b error (inaccessible boot device, you may need to fix system registry hive to use standard ide but it's tricky and you need a windows box or of course a working windows vm :D)

contact me if interested (sherpya@netfarm.it)

anonymous comment, 23 months ago
I've fixed the compilation error and made it 64bit aware, I still need to test it anyway here the download link:

http://oss.netfarm.it/download/vhd2img-64bit-aware.tar.bz2

(use wget or direct link, a link from a page will cause 503)

anonymous comment, 25 months ago
Hello again,

Well, err, uh, duh!  I poked around in the .c file and removed the whole license preamble then it compiled just fine.  Sorry about that.  It worked great but the resulting .raw and converted .qcow2 file give me a BSOD when run with kvm.

Thanks,
Patrick.
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