9

I am looking at transforming a VMDK hard drive into a VHD (Virtual Hard Drive). The VMDK comes from an export of our VMware machines and I want to try importing it into Azure.

Any idea how this would be achieved ? I tried a variety of small tools out there to try to move between the 2 formats, to no avail so far. Most tools declare the VMDK invalid in some way.

6 Answers6

10

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/

Craig
  • 384
8

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!

4

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.

spuder
  • 10,135
0

The answers by @ElvisLives and @AvkashChauhan are good, but for those that are not scared of using the powershell this is a great solution.

  1. First you will need to download and install Microsoft Virtual Machine Converter 3.0 from Microsoft’s website.
  2. Next, open an elevated PowerShell prompt and run these commands (changing the paths to match your source VMDK file and destination path of your new VHD file):

    -Import-Module ‘C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1’

    -ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath “C:\Ubuntu-disk1.vmdk” -DestinationLiteralPath “C:\Ubuntu-disk1.vhd” -VhdType FixedHardDisk -VhdFormat Vhd


When doing it like this no need for RDP

davejal
  • 553
0

An updated version of VirtualBox is using vbox-img.exe. You can install virtualbox without all its features just to get this tools in your environment.

Sintax:

.\vbox-img.exe convert --srcfilename <source_disk> --srcformat VMDK --dstfilename <destiny_disk> --dstformat VHD --variant

Example:

.\vbox-img.exe convert --srcfilename "F:\Disk\DC02-0.vmdk" --srcformat VMDK --dstfilename "F:\Disk\DC02.vhd" --dstformat VHD --variant Standard

f4d0
  • 233
0

I have used the tool suggest by rkosegi and it did converted by VMDK to VHD and I could use locally. With regard to your "Invalid vmdk file" error, this could be specific to the VMDK you have as not everyone using this tool report same error.

Based on my experience on using converted VMDK on Windows azure, what I found is that not all VHDs which are converted from VMDK will work on Windows Azure. There were few problems reported after VHD was installed with Windows Azure Integrated components and deployed to Windows Azure.

So to get best experience, it would be best if you generate your OS VHD native and then deployed to Windows Azure. And if you start creating your native VHD directly, you will be sure that it will run on Windows Azure as expected.

Ian Kemp
  • 1,086
  • 11
  • 18