Skip to main content

VirtualBox Corrupts My VMware VMDK Files!

I hate it when I’m stupid.virtualbox-logo-1

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
#DDB

ddb.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

Comments

  1. Wow, impressive save.

    No 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.

    ReplyDelete

Post a Comment

Popular posts from this blog

Kernel-based Virtual Machine hits Linux

Many congratulations to my good friend Moshe Bar and his team over at (stealth-mode startup) Qumranet . Techworld reports that the KVM (Kernel-based Virtual Machine) project has been accepted into the 2.6.20 version of the Linux kernel distribution. KVM is an Open Source kernel driver that basically allows a Linux kernel to host virtual machines, as plain old Linux processes, that can run Linux or Windows (or other x86-based operating systems). It runs only on hardware that support Intel's VT instruction set (which is fine) and will soon support the AMD-V instruction set as well. This is cool for a number of reasons. It's Open Source, released under the GPL. It basically turns the Linux that we all know and love into a "hypervisor". Linux-as-hypervisor makes sense because Linux already knows how to manage devices, memory, processes, multi-cores, etc. VMware ESX is, essentially, a "hypervisor" - a small kernel, built on Linux as it turns out, that

Bill Coleman Joins 3tera Advisory Board

I think this move surprised a number of people, since Bill recently wrapped up Cassatt Corproation, getting the technology and people  acquired by Computer Associates . However, I was not surprised at all. The announcement, via  3tera Welcomes Bill Coleman : You may or may not have seen the recent press realease.  Bill Coleman, IT/Silicon Valley luminary, Founder and CEO of BEA Systems, has joined 3Tera’s Advisory Board. Yes, this alone is a great testimonial to what we have accomplished in our field.  Getting dignitaries such as Bill does not come easy.  But here’s the best part - this has a lot more than just marquee value and I doubt that Bill would have joined us if that was the case.  Bill, especially since his most recent stint as Founder and CEO of Cassatt Systems, is an extremely knowledgeable visionary in the area of utility and Cloud Computing; and, data center automation. So, Bill will be extremely valuable, reviewing and tweaking both our business plans and techno

Big In Japan Open Sources Their Ruby On Rails Tools

The kind folks over at Big In Japan have graciously decided to Open Source the code they used to build their demo web sites . It's all Ruby on Rails code, and it's being released with a GPL license. The code trees being made available include: elfURL ~ URL Shortner FeedVault ~ OPML file storage FrankenFeed ~ RSS feed merger InstantFeed ~ RSS feeds via email QwikPing ~ Ping Server SocialMail ~ RSS via email Very cool. I just love the Open Source community . I have actually been writing some code of late, and it's great to have some reference code to check out. Not sure if I'm going to go with Ruby on Rails yet, however. And, for the record. I have no idea if this is big in Japan. Tags: Open Source , GPL , Ruby On Rails , Big In Japan , Brian Berliner , brianberliner