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.