Disk2VHD on a Generation 2 VM results in an unbootable VHDX

Most people who have been in IT for a while will know the Windows  Sysinternals tools and most certainly the small but brilliant Disk2VHD tool we can use for Physical To Virtual (P2V) and Virtual to Virtual (V2V) conversions. It’s free, it’s good and it’s trustworthy as it’s made available by Microsoft.

For legacy systems, whether they are physical  with IDE/SATA/SAS controllers or virtual with an IDE generation 1 VMS thing normally go smooth.

image

But sometimes you have hiccups. One of those is when you do a V2V of a generation 2 virtual machine using Disk2VHD. It’s a small issue, when you create a new generation 2 VM and point it to the OS vhdx it just won’t boot. That’s pretty annoying.

image

Why do a V2V in such a case you might ask. Well, sometimes is the only or fasted way to get out of pickle with a ton of phantom, non-removable checkpoints you’ve gotten yourself into.

But back to the real subject, how to fix this. What we need to do is repair the boot partition. Well recreate it actually as when you look at it after the conversion you’ll notice is RAW. That’s no good. So let’s walk through how to fix a vdhx that your created from a source generation 2 Hyper-V vm via Disk2VHD.

First of all create a new generation 2 VM that we’ll use with our new VHDX we created using Disk2VHD. Don’t create a new vdhx but select to use an existing one and point it to the one we just created with Disk2VHD. Rename it if needed to something more suitable.

Don’t boot the VM but add a DVD and attach the Windows Server ISO of the version your vhdx contains to the DVD.

image

Move the DVD to the top of the boot order I firmware.

image

The VM will boot to the DVD when you hit a key.

Select your language and keyboard layoout when asked and the don’t install or upgrade the OS but boot

image

image

 

image

 

 

image

 

image

Type diskpart and  list the disks. Select the disk we need (the OS disk, the only one here) and list the volumes. You can see that volume 3 off 99MB is RAW. That’s not supposed to be that way. So let’s fix this by creating boot loader directory structure, repair the boot record by creating the boot sector & copy the needed boot files into it.

Type:

select volume 3

assign drive letter L:

FORMAT FS=FAT32 LABEL=”BOOT”

That’s it we can now us that 99MB volume to make our disk bootable to windows again.  Type Exit to leave diskpart.

image

So now we have a formatted boot partition we can create the need folder structure and fix the boot record and configure our UEFI bootloader

Switch to the L: volume

create efi\microsoft\boot folder structure for the bootloader as show below with the md command(make directory)

Type: bootrec /fixboot to create the bootrecord

Type: bcdboot C:\Windows  /l en-us /s l: /f ALL

This creates the BCD store & copies the boot files from the windows system directory

 image

Just click Continue to exit and continue to Windows Server 2012R2

image

.. and voila, your new VM has now booted.

image

Now it’s a matter of cleaning up the remnants of the original VMs hardware such as the NIC and maybe some other devices. The NIC is very important as it will have any static TCP/IP configuration you might want to assign tied to it which mean you can’t reuse it for your new VM. So, the 1st thing to do is uninstall the old network adapters from device managers, you’ll see them when you select “show hidden devices” in the view menu.

Good luck!

24 thoughts on “Disk2VHD on a Generation 2 VM results in an unbootable VHDX

  1. Thanks so much for helping me out of this bind!

    You can create all the directories in one go by doing
    mkdir -p L:/efi/microsoft/boot/

    • Your welcome. Good tip by they way. FYI: I’ve send a request to Microsoft to have this fixed in Disk2VHD, not sure if it’s a priority for them, but it has been asked.

  2. Many thanks. I used your instructions to get a windows 10 machine running that was not booting. The windows 10 disc and the same instructions worked. The only issue I had was that it would not work as Generation 1, but when I changed it to Generation 2 it booted.

    So thanks again, as aggravating as this was it was very helpful to have your help.

    Cheers!

  3. Absolutely awesome solution. Have tinkered and failed with this sort of conversion previously, but your guide is so succinct and easy to follow! Well done…..

  4. Hi, this is an amazing article,,thank you very much.
    One question though, it worked on one VM i created but on a second one at the last stage where you execute the bcdboot i get the following message “Failure when attempting to copy boot files” this VM had 2 RAW volumes .
    Any suggestions..thank you very much

    • I ran into this issue previously and it turned out that the volume was too small, so it probably failed to copy all necessary files. I picked a much larger volume and was able to proceed just fine. A tiny bit more space wasted but at least it worked. You can check to see if this applies to you.

Leave a Reply