Friday, January 2, 2009

Convert VMware VMDK to Virtual PC VHD

I had a virtual machine setup using VMware on my Windows XP desktop. This VM was also running Windows XP. So both the host and guest OS was Windows XP. I use it for maintenance of an old system that I didn't want to load and configure on my every-day desktop. I'd been using this VM with the free VMware Server product successfully for a couple years. I always figure that VMware was better than Microsoft's Virtual PC, but I was never really comfortable running VMware Server because technically it's not supported on my Windows XP desktop OS, even though it installed and appeared to work.

For various reasons I decided that I wanted to use Microsoft Virtual PC 2007 SP1 instead (also a free product). I didn't want to format and install everything new inside a new VPC VM, so I set out to find a way to convert my VMware VMDK virtual hard disk to a VPC VHD virtual hard disk.

My searches didn't find a magic bullet. I see that VMware has a tool to suck an OS (and possibly even a VHD) directly into a new VMDK. Why doesn't Microsoft have such a tool? They have some kind of Windows Server kit that will do something like this, but it requires extra software and all sorts of stuff to make it happen. Not lightweight at all. I thought maybe I could simply convert a VMDK to a VHD. Even if I could do that, when the OS booted up in VPC it would probably blue screen (BSOD) because all the hardware would look different in VPC compared to VMware. Kind of like taking a Windows XP image and moving it to totally different hardware. I found various long and complicated explanations of how someone might be able to do this conversion. None of these looked easy enough for me to quickly follow. I was feeling a little bit rushed and lazy today and didn't want to jump through hoops to make this happen.

I ran across WinImage. Its a really nice tool. This product is not free; its shareware. One of the many things this product will do is actually convert a VMDK directly to a VHD. Wow! All this searching for tools but nobody mentioned this thing. So here's what I did to do my conversion and it appears to have worked very well:

  1. Make a backup of the original VMware VM (the VMDK file). This process could hose up everything so you want to be sure to have a backup.
  2. Crank up VMware on the original VM. Uninstall the VMware tools and any other tools/apps/deivers you may think won't work in VPC. The only thing I uninstalled was the VMware tools.
  3. Run Sysprep to prepare the system as if it were a new PC you were deploying. Sysprep will clean all the hardware specific settings out of the OS then shut down the VM.
  4. At this point your VMDK looks like an OS on a system that someone like Dell ships out. The next time its started it will go through a mini Windows setup process, establishing all the hardware specific settings, etc.
  5. Run WinImage and convert the VMDK to a VHD.
  6. Install VPC 2007 SP1, create a new VM and point it to this new VHD. Then crank it up.
  7. Windows XP will go through the mini setup process in the new VPC VM environment and when you're done everything works.

I couldn't believe this actually worked as well as it did. It was pretty smooth and didn't require too much effort. Sysprep isn't hard to work with so don't let it scare you. When the VPC VM first booted up the mouse did not work. I had to do everything with the keyboard. Once I installed the VPC Tools it started working and everything is just fine now.

This isn't really a novice process and I didn't explain the steps in enough detail for a beginner to understand. I figure you're probably like me, someone who knows a little about what they're trying to do and looking for a way to convert from VMDK to VHD with minimum effort. So I hope this tip helps you out. Good luck.

5 comments:

DaveF said...

Excellent!

I'm going to try this on the new Win 7 beta.

When you try to install Win 7 beta in VPC 2007 it just hangs on "Expanding Files...0%..."

When installed in vmware it installs fine.

So.... I'm going to try to use your solution to see if I can convert the vmdk vm of Win 7 into a vhd version!

I'll let you know if it worked...

Dave Franklyn, MCT, MCSE, MCITP SA, EA, EMA, EST

Brawney said...

DaveF - glad you liked my tip. I did this a couple times and it worked every time.

I downloaded Win 7 Beta (build 7000) and installed into a VPC 2007 SP1 VM without any problems. Seem to run a bit slot with only 1MB of RAM allocated to it though.

DaveF said...

Hey, thanks! I tried a vpc install again--I redownloaded and installed directly from the iso rather than first burn to dvd. That worked.

Still, your tip will help me since I use vmware converter to make vm's from various physical machines and now I can transfer to vpc!

DaveF

Shaul B said...

WinImage is not so intuitive to use - I couldn't work out how to convert the VMDK to VHD. Please can you add clearer, step-by-step instructions how to do that?

Shaul B said...
This comment has been removed by the author.