Converting a VMDK to VHD

The Microsoft Virtual Machine Converter (MVMC) includes the Microsoft Virtual Disk Converter tool (MVDC.exe) that converts a VMDK file to a VHD file.

http://www.microsoft.com/en-ca/download/details.aspx?id=42497

MVDC SrcDisk  DstDisk  [/?]  [/Dyn]

SrcDisk  Specifies the source VMDK disk path to be converted.
DstDisk  Specifies the path for the converted disk.
[/?]     Show Help
[/Dyn]   Indicates the destination disk should be dynamic rather than fixed.

For example:

C:\Program Files (x86)\Microsoft Virtual Machine Converter Solution Accelerator>mvdc "D:\VM\Windows Server 2008 R2 x64\Windows Server 2008 R2 x64.vmdk" "D:\VM\Windows Server 2008 R2 x64\Windows Server 2008 R2 x64.vhd"
Step 1 of 3: Loading Source Disk...
Step 1 of 3: Loading Source Disk Completed.
Source file found of size 40.0 GB.
DiskGeometry:
   Cylinders:        5221
   Tracks/Cylinder:  255
   Sectors/Track:    63
   Bytes/Sector:     512
   MediaType:        FixedMedia
Step 2 of 3: Creating Destination Disk...
Step 2 of 3: Creating Destination Disk Completed.
Destination file created of size 40.0 GB.
DiskGeometry:
   Cylinders:        5221
   Tracks/Cylinder:  255
   Sectors/Track:    63
   Bytes/Sector:     512
   MediaType:        FixedMedia
Step 3 of 3: Copying raw data...
Step 3 of 3: Copying raw data completed.
Conversion Complete!  The converted file is located at: D:\VM\Windows Server 2008 R2 x64\Windows Server 2008 R2 x64.vhd

By default it creates a fixed sized VHD, which is also what is required for Azure VMs.

After converting it to VHD, it is a good idea to boot it up locally in Hyper-V, make sure it is configured for a dynamic IP and that RDP is enabled and you are able to successfully RDP into it. Then if you want to use it as a base image, you'll also need to generalize it with sysprep. If you want to use it for a single Azure VM, don't run sysprep, but upload it as a disk instead of as an image (Csupload Add-Disk instead of Add-PersistentVMImage).

See also: http://www.windowsazure.com/en-us/manage/windows/common-tasks/upload-a-vhd/


I use VirtualBox (actually the CLI vboxmanage, installed with VirtualBox) for this, I had no issues installing VirtualBox alongside Hyper-V, but you can't run them at the same time, thats another thread!

Anyway at an elevated (Admin mode) prompt use

cd %programfiles%\Oracle\VirtualBox

vboxmanage clonehd "C:\tmp\file.vmdk" "C:\tmp\file.vhd" -format VHD

Note, You can extract a VMDK from an OVA with 7zip!


There has been an update to the tool to convert a .vmdk to a .vhdk.

Microsoft Virtual Machine Converter 2.0 was released around April of 2014.

Here is the link to the tool: Microsoft Virtual Machine Converter 2.0

The new tool changes the way to convert from using MVDC.exe to using a powershell cmdlet.

I followed this excellent blog to figure this out. What's new on Microsoft Virtual Machine Converter 2.0

Here is a detalied summary of how to do it.

The default install location is:

C:\Program Files\Microsoft Virtual Machine Converter

Using powershell as a local admin you can then load the cmdlet:

Import-Module .\MvmcCmdlet.psd1

After the cmdlet is loaded you can call the following:

ConvertTo-MvmcVirtualHardDisk

This will ask for the .vmdk file path:

Supply values for the following parameters:

SourceLiteralPath: D:\some.vmdk

It will then start the conversion and place the .vhdk in the following path after its converted:

C:\Program Files\Microsoft Virtual Machine Converter

I hope this helps someone else.

Tags:

Azure