Friday, April 11, 2014

HOW TO: Migrate large VMDK content to VHD when everything else fails

The Task: 
Migrate our lab server (IBM x3655) - so that it supports Windows 8. 8.1 and equivalent server versions - from  ESXi 3.5 Update 5 (Highest version officially compatible with the hardware) to Hyper-V 2012R2.

The Setup: 
Staged a desktop with windows 8.1 and Hyper-V to use as a "pivot" to store my converted VMs and ensure they do work properly before reinstalling the Server OS.

The Problem(s): 
After I had successfully converted over the network my smaller VMs ( Disk of 40GB or less) using 5nineEasyConverter I could not convert the larger VMs this way and would get conversion errors of some sort.
I spent a lot of time testing different products including WinImage and VMDK2VHD but did not have much success.

The work-around : 
Out of options, I decided to boot my VMs on a WinPE image and use IMAGEX to capture their content to a WIM file to then apply this to a new VHD(X).

Note that regardless of the method you use when converting your VMs from one vendor to another always uninstall the "integration" software from the VM before hand. If you use all in one converters like the one mentioned above also ensure your VMs don't have any snapshots, since in this instance we are capturing the disk content, we don't really care about snapshot and this method could be used if you are unable to merge your snapshot with your VM for whatever reason.

Since capturing VMs running in iSCSI mode and migrating those to IDE mode in HyperV, extra steps were required (point #7 and following) to fix the boot error "0xc000000e The boot selection failed because a required device is inaccessible.".

1. Map a share from  in the WinPE environment to the box where you want to store your migrated VMs.
2. Put a copy of Imagex.exe on the WinPE RAM Disk under X:\Windows\System32 for ease of use.
3. Run: Imagex /CAPTURE C:\ Z:\MylargeVM1.WIM "My Large VM OS Disk"
4. Let the capture finish ( it does take a while but less than any of the other products tried before).
5. Create a new VHDX on your "pivot" box with Diskpart, attach it, create a primary partition, format it, make the partition active (else it wont boot either) and assign a letter to it (i.e.: F:).
6. Apply the WIM to the new VHDX by running:  Imagex /Apply D:\MylargeVM1.WIM 1 F:\
   Note: At that point I did detach the VHD, created a new VM in Hyper-V using this existing disk but the VM failed to boot and was throwing an error "0xc000000e The boot selection failed because a required device is inaccessible." The following steps are to apply the fix KB314082 to solve this problem.
7. Mount the SYSTEM hive of your new VHD(X) in the "pivot" box registry editor:
   From Regedit, select HKLM and go to File > Load Hive. Navigate to F:\Windows\System32\config and select SYSTEM. Mount the hive as Z.
8. Copy the entries under "Windows Registry Editor Version 5.00" from KB314082 to a .reg file and replaced "HKEY_LOCAL_MACHINE\SYSTEM" with "HKEY_LOCAL_MACHINE\Z\SYSTEM".
9.  Run the newly created .REG to add the entries to the loaded SYSTEM hive.
10. Unload the Hive, Detach you VHD, Create your VM in HyperV and boot it up. Hopefully you should be all good.

I hope this will be useful to a few and if you have other solutions please do use the comment section to share them! Enjoy !!