I started blogging again, and wrote about how I am now using Windows Live Writer as my blog editor. Problem is, that I use Mac computers exclusively, so I needed to run WLW under VMware Fusion (inside a Windows Virtual Machine).
That works pretty well, for the most part, but VMware Fusion does not do copy/paste of images between the virtual machines (yet). And, since I like to include an image with every post, it’s kind of a pain to save the image to a file under Mac OS X only to turn right around and load the image into Windows Live Writer. For me, the writing process is enhanced when friction is removed from the process.
So, I thought, naively, that perhaps the free VirtualBox tool might have this capability. Download the product and install it on my Mac OS X Leopard Server and give it a go. The VirtualBox site says that you can use your existing VMware VMDK (Hard disk image) files with VirtualBox. There is evena video showing you that it works great. The VirtualBox User manual says:
Starting with version 1.4, VirtualBox also supports the popular and open VMDK container format that is now supported by a large number of virtualization products. This means you can import your existing VMDK files by way of the Virtual Disk Manager just like existing VDI images; see chapter 3.5, The Virtual Disk Manager, page 34. While VirtualBox fully supports using VMDK files in most situations, the more advanced features of virtual hard disks are presently not supported.
After trying, and failing, to import my VMDK files into VirtualBox, I found, much to my dismay, that my VMDK files were trashed by the VirtualBox import and no longer readable by VMware Fusion. The term "import" usually implies that it is non-destructive. Nope.
I blamed the Fusion failure on the Apple Security Update that I had just installed. Silly me.
After quite a few hours of reading VirtualBox code and poking around with the VMware VMDK on-disk formats, I was able to "patch" my VMDK files into something that Fusion would once again read. Take a look at the VMware Community Forum article for detailed history.
In the corrupted VMDK that was mucked with by VirtualBox, mine looked like the following:
# Disk DescriptorFile
version=1
CID=4c06b51e
parentCID=f6d5af3d
createType="monolithicSparse"
parentFileNameHint="AmyOffice.vmdk"# Extent description
RW 41963828 SPARSE "AmyOffice-000001.vmdk"# The Disk Data Base
#DDBddb.toolsVersion = "7362"
ddb.virtualHWVersion = "6"
ddb.uuid.image="309b24ab-4acf-4b11-cbbe-f6935882d848"
ddb.uuid.modification="12ff42d5-f691-4ba3-7abb-6686efa6d59f"
ddb.uuid.parent="00000000-0000-0000-0000-000000000000"
ddb.geometry.cylinders"0"
ddb.geometry.heads"16"
ddb.geometry.sectors"63"
ddb.geometry.cylinders="0"
ddb.geometry.heads="16"
ddb.geometry.sectors="63"
And, it was padded by NULL characters. I extracted it from the VMDK using "dd":
# dd if=AmyOffice-000001.vmdk bs=512 skip=1 count=2 > out
I didn’t like the look of the entries: Note that there is no equals sign between the cylinders/heads/sectors section at the bottom and the values. That did not sit well with me at all. Nor did I like the value of the cylinders was 0 and the heads/sectors did not match the binary values in the first data structure after the MAGIC KMDV in the VMDK file.
Badness.
Comparing this text header info with a very old backup of my VMDK file, it appeared that I could drastically simplify this section.
So, I did.
I edited the "out" file, and made the following changes:
- Changed the CID to 613506eb
- Deleted everything after this line (but keep it in): ddb.toolsVersion = "7362"
- Extended the NULL padding at the end to get the file back up to 1024 bytes exactly.
Then, I patched the VMDK with the following command:
# dd conv=notrunc if=out of=AmyOffice-000001.vmdk bs=512 oseek=1 count=2
Don’t forget the "conv=notrunc", or your VMDK file will be truncated (which I did, and had to copy over from backup again, sigh).
And, guess what? The VMware Virtual Machine booted up with no problem!
I promptly uninstalled VirtualBox. You get what you pay for sometimes.
Now, if I could just get Time Machine to efficiently backup my 30GB Windows VM…
Tags: VirtualBox, VMware Fusion, VMware, Fusion, Virtualization, Open Source, Brian Berliner,brianberliner
Wow, impressive save.
ReplyDeleteNo software is perfect (not even Mac OS X, grin). But I've had my share of badness for not making a working copy.
Also, if you weren't able to save the VMDK, perhaps data could've been salvaged by using one of VMWare's disk mount tools.
Thanks for the post; again, impressive save.