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.
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.
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.
Move the DVD to the top of the boot order I firmware.
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
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.
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.
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
Just click Continue to exit and continue to Windows Server 2012R2
.. and voila, your new VM has now booted.
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.
You, sir, deserve a medal.
Wow. So handy. Thanks.
Fantastic article. Thanks so much for writing this up.
Thank you, thank you, thank you. This article really helped me and I very much appreciate that you posted it here.
I’m happy to read it helped you out 🙂
Oh Yeah ! THank you so much !
You’re most welcome.
Absolutely awesome – Thanks for saving me hours of stress!
Cool, that’s why I wrote it up. I’m glad it helped 🙂
Awesome. Saved my bacon. Thx muchly
You’re most welcome. Happy it helped and thank you for reading 🙂
Worked like a charm!
Glad it helped, I wrote it as I saw many people running into the issue.
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.
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.
You sir, is a genius. Thank you for sharing this document, which saved me A LOT of time!
Happy it helped! Thx for reading.
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…..
Glad to be of assistance.
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.
Interesting, I’ll have to verify that in the lab. Thx for sharing.
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
Thank you! You helped me very much!
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.
This was extremely helpful for a Windows 10 disk2vhd UEFI laptop setup in a Hyper-V cluster. Thank you Sir!
You are most welcome!
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
You are a hero! Thank you! I’ve been wrestling with VHDX that I could not get to boot. I just wish I’d found this post a lot sooner. 🙂
Thanks it work with me like charm 🙂
Happy to read it helped!
Thanks, work fine.
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 🙂
Thanks, it helped me. Nice blog…
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!
Happy to read it helped you out José!
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.
Happy to read it helped you. Thx for sharing and a happy new year!
Thanks… This post save my life!!!
Excellent article! This fixed my problem after I finished the steps. You are a lifesaver!!
Excellent, thx so much this worked beautifully!!!
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.
Thank you so much for this article.. You save me and my JOB…
Glad I could be of assistance.
Awesome !! This worked out straight away! Great work, thank heaps !
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, glad you found it and it helped you!
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 🙂
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
Need your help, once i reach to CMD to type the command the keyboard dont type. any solution for this?
I got the same issue.
ISO used to boot VM Gen 2
Thank You So Much For Sharing , Clear and Perfect
You are most welcome.
I think I love you! thank you so much! it works even with a WS2012 vhdx and W8 iso.
Worked like a charm !
Many thanx for this fix <3
Thanks for this! Worked perfectly after I used disk2vhd to P2V one of my Windows Server 2019.
Happy it helped you out!
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?
Excellent procedure works perfect.
Thanks for the document,
Dude – Thank you!
Amazing! Thank you very much! Worked like a charm!
You are most welcome
You saved me! Was at wits end and this saved me. Keep up the good work!
Thx, happy it helped!
Excelent article, thanks ! You saved my @ss ! 🙂
Happy to hear it helped you out!
Thanks for your help.
This was written very clearly described the steps need to fix this.
Thanks again, save me lots of time….
I am happy to hear it helped you out. Thx.
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.
Glad it helped!
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!
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.
It seems your actions are not persisted, any issues logged?
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….
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.
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
Thanks for the detalied explanation! It really works!
You are most welcome. Yes, it does work 😉
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….
Was the physical machine classic BIOS or UEFI? If classic BIOS use a generation 1 VM. Also see https://docs.microsoft.com/en-us/archive/blogs/jonjor/vm-does-not-boot-following-p2v-or-disk2vhd
This is fantastic post and helped save our life… thanks a lot!
Happy to hear it helped you out. Thanks for letting me know.
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…
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.
Why, thank you, sir. Happy it helped!
December 2020 and still helping folks out. Thanks a zillion!
You are most welcome!
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.
This absolutely worked on a server 2016 P2V made with Disk2vhd. You’re a legend mate.
Thank you. Glad it helped.
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??
Normally unrelated. Many issues can prevent an ugrade. Stat by running the DISM commands to check & restore health: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/repair-a-windows-image check the logs and dive in to find the root cause.
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
You can always get it to work on a generation 1 virtual machine. When that is all done you can convert a generation 1 virtual machine to a generation 2 virtual machine with a script John Howard (MSFT) created many years ago. Take a look here for the latter https://blog.workinghardinit.work/2017/02/27/tips-on-using-convert-vmgeneration-ps1-with-windows-server-2016/ I have adapeted the script successfully to work on Windows Server 2019 and will soon have to domit to run on Windows Server 2022.
Pingback: ИТ Вестник №09.2016 - Блог IT-KB
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.
Glad to hear it helped you out! Take care.