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!

59 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.

    • I got the “Failure when attempting to copy boot files” error as well. It turned out that it was caused by the D: drive letter being assigned to the volume with Windows on it. I just needed to adjust the bcdboot command for that.

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

  5. Thank you this worked for Windows 10 but NOT Windows 7. I got errors in the last stage saying

    BFSVC Warning: Failed to determine source OS Version
    BFSVC Warning: Resource Files missing from c:\windows\boot\Resources
    BFSVC Warning: SerciceDebuggerFiles: C:\Windows\boot\BootDebuggerFiles.ini does not exit.

    When I tried to boot the New VM it simply hangs

    • Windows 7 32/64 bit is not supported on a generation 2 VM, the UEFI Boot module doesn’t support 32 bit and both 32/64 bit need a PIC that isn’t present in generation 2. So probably you boot issue had a different cause.

  6. Thank you very much sir !!

    really really help a lot.. i’ve been confused for a long time when create hyperv gen 2 using disk2vhd

    thanks alot

  7. made my day… thanks a lot. Was searching for hours, but this didi it.
    Windows 2012R2 Backup with DISK2VHD.
    Imported in 2012R2 Hyper-V, no boot.
    Now it works… lots so easy 🙂

  8. Thank you very much, helped me a lot and worked like a charm. In mi case, I was using a Spanish version of Server 2012 R2 and changed bcdboot C:\Windows /l en-us /s l: /f ALL to bcdboot C:\Windows /l es-es /s l: /f ALL

    Many thanks for your article! Was desperated about this!

  9. Awesome post, this same process has enabled me to restore a VM using Shadow Protect HSR (Head Start Restore) to create Gen 2 VHDX from an operational VM.

    The Shadow Protect Recovery Environment could not fix the BCD error no matter what I tried.

    Regards
    Tony

  10. The article attributes this problem to doing a V2V, but this happened to me when doing a P2V. It might just be a problem with using Disk2VHD with Windows Server 2012 R2.

    • No I don’t think so. It has to do with EUFI (gen2 VMs are UEFI), not the OS version. Future versions might fix this. And similar issues can occur due to different reasons. You mileage may vary.

  11. Hi workinghardinit,
    I had to come back and comment, I stumbled on the SOP regarding disk2vdh and though yah its another non working solution from the many I tried and from people claiming that they followed their solutions to the T and it worked. Man was I proven WRONG first try and I have the VM up and running that I struggled with the whole of last week. You my man deserves a medal. Thank You very Much!!!!!!!

    Thanks,

  12. I really wish I had found this article first, walked through with it and sorted, really good and so thankful! Now I can move forward to the next challenge 🙂

  13. Thanks for this, it worked on my disk2vhd W2012R2 Physical 2 Virtual conversion. However I had tried this process a few times and it did not seem to work, just booted to same error as before in hyperv manager, my image file was on a local D: iscsi drive (from NAS) as it was 1TB in size, not sure if this made the difference but before the time this process actually worked I added the “everyone” group on the local workgroup W2012R2 hyperv host server with full permissions to the folder where the image file was, run this process again and it worked! So either a typing error from me or the permissions fixed it. Funny thing is i have converted a few servers before and don’t think I ever had this issue…Cheers

Leave a Reply

Your email address will not be published. Required fields are marked *

* Checkbox GDPR is required

*

I agree

This site uses Akismet to reduce spam. Learn how your comment data is processed.