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!

106 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

    • I got the same issue.

      ISO used to boot VM Gen 2
      SW_DVD5_Win_Svr_Std_and_DataCtr_2012_64Bit_English_Core_MLF_X18-27588.ISO

  14. Great article, thank-you for publishing. I have a Windows 10 Pro VHD file I created with disk2vhd. I have created a Virtual Box Machine with this disk file and have followed your instructions. I am unable to mark the BOOT partition as ACTIVE.

    When I boot I get a Fatal Error: INT 18 Boot Failure. I only cloned the C: drive, not the boot or recovery partitions. They exist in the VHD image, however they are listed as RAW disks.

    I have read that VirtualBox does not support EFI with Windows Guests, perhaps this is the problem. My host is MacOS.

    Any ideas how to get it booting again?

  15. just wanted everyone to know these instructions worked for a server 2016 machine as well. Moved from P2V and would not boot ran across this article and tried it…..wambamthankyoumam it worked.

  16. I was at my wits end until I found this. I was also about to get even more frustrated before saw the comment about it only working on V2 machines. I had a VM set-up as a V1 and applied your fix with no luck. I deleted the VM and added back as a V2 with the same disk and BOOM!!! It worked! Thanks!!!!! If you ever come to the Columbia, MD area you’re due a cup of coffee on me!

  17. Hi

    Excellent article and has helped me reach furhter than any other solution but not there yet.

    I converted a phyiscal server with RAID config and all. Partition size is 2.7TB.

    Followed your instructions to the T but when I boot the machine it keeps blue screening with message “your PC ran into a problem and needs to restart”.

    Any ideas at all?

    I went back in to the “repair your computer mode” and the 100 MB partition had gone back to RAW from FAT32.

    Dhaval

  18. Thanks a Million for that aticle. Saved me hours. I use disk2vhd for years converted a dozend of drives/machines with, but sometimes I’m lacking knowdlege regarding boot sectors. Thank you for this one. Will it also be possible to reinstate a old-style IDE drive boot sector on a Gen2 SCSI drive? Need to downgrade a 2016 vm….
    Peter

    • It should be possible, but I have never done it. As long as you have the data partition intact and have room to work on the dis, that should work.

  19. Hi there. These instructions made sense and were well laid out. I used disk2vhd to move a Windows 7 Ultimate installation to VirtualBox, which was originally drive D: on the Windows 7 machine. Your instructions seemed to do the trick (except for the /f ALL option seemed to be rejected) as I booted from a Windows 7 ISO. Then when I booted from the virtual HDD, it starts ok and then gives a BSOD. Tried to boot in SAFE mode to remove the drivers but got the BSOD as well. Any tips??

    • The generation 2 issue is related to Hyper-V VMs. So moving an old physical machine is a bit of a different beast. The main reason for failure is not having selected the hidden system partitions along with the boot partition. Now virtual box on Windows 10 is not going to work without turning off or not using many of the security built-in to Windows 10.

      Diving into the IT-specific intricacies of booting a disk. While this can all be done, doing so over e-mail or comments is very time consuming and tedious. But if the Disk2VHD went well and you have all the partitions look into BCDedit to check partition you boot from if not check this post on how to deal with hidden partitions. https://superuser.com/questions/1070984/disktovhd-generated-vhd-is-not-bootable

  20. In my case…. I have only got C drive which I p2v to VHDX file… There is no recovery partition… It has only C drive….
    Do you have any suggestion for the same….

  21. i have complete the steps yet i do not have to option to continue to boot to windows server 2012R2. i only have the option to see the command prompt or the system recovery tools. the file and folder structure are there…any thoughts on how to make this work…

  22. I have trying to solve this issue on a Windows 2016 Server for a week, following a variety of articles. Your article worked in 10 mins.

    You, sir, are a legend.

  23. Still relevant in January 2021! I used your method to restore a Windows Server 2012. Non R2. When I reached the command prompt, the keyboard don’t work. I used the method in https://docs.microsoft.com/en-us/archive/blogs/jhoward/hyper-v-generation-2-virtual-machines-part-4, to inject a CAB file which contains the integration service into a ‘customized’ ISO. Then I used that ISO to work through your procedure and successfully boot my Win 2012 Server. Thank you so much for posting this article. You should get a medal for this.

  24. Thank you very much, it helped me to boot my VHD of my servers. But i’m having an issue now i can´t update the windows and i can not upgarde it to 2019. Maybe you have some information about that, or somebody could help me??

  25. Hi, I think you nailed it with this awesome article. Peculiar use case here but still wanted to get your opinion: Windows 7 P2V conversion using Disk2VHD and the end result was .vhdx. The source box had IDE controller and Gen 2 VMs can only have SCSI. Is there any hope for me here? Thank you

  26. Pingback: ИТ Вестник №09.2016 - Блог IT-KB

  27. Hello.
    I just want to say simple Thank You!

    you don’t even know how long I have been looking for a solution and how many have I tested. It’s good that I found you.

Leave a Reply, get the discussion going, share and learn with your peers.

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