Reusing vhdx (native boot) in Hyper-V


  1. Posts : 3
    Windows 10 Pro x64
       #1

    Reusing vhdx (native boot) in Hyper-V


    Hey all,

    I created a .vhdx in disk management, initialised, new volume and formatted.

    Deployed Win 10 Insider 17754 to it using dism /apply-image etc. Updated the bcd store on main OS, booted to .vhdx natively no issues.

    Now since MSoft doesn't allow the upgrade to newer builds for vhd's I wanted to attach the .vhdx to a virtual machine in Hyper-V (on my main install obviously) and then perform the upgrade process.

    Tried creating a gen 2 machine, attached the .vhdx, didn't boot. Tried attaching an .iso of the Win10 install also, still didn't boot.

    Created a gen 1 machine, with both .vhdx and .iso attached, it booted from the .iso but said no disk drive was detected/installed.

    I tried using the repair computer option, setup couldn't repair it, so loaded up command prompt used diskpart, it picked up the drive, marked the current partition active, and tried to manually enter the following commands:

    bootrec /fixmbr (successful)
    bootrec /fixboot (fail) said something like access denied
    bootrec /rebuildbcd (success)

    Restarted the VM in Hyper-V still not booting from the attached .vhdx nor did the install from .iso detect the drive either.

    Any suggestions as to how I can boot from the vhdx and upgrade the windows installation to build 17760 and then reuse the same .vhdx to boot natively?

    Regards
      My Computer

  2. cereberus's Avatar
    Posts : 11,344
    Windows10
       #2

    Problem is your native vhd does not contain boot files. If you install it in vm first, then mount as vhd, you can add a boot entry.

    If you have apps etc in existing vhd, do this.

    Image backup C drive in current vhdx using Macrium Reflect Free.

    Clean install 17754 in Hyper-V using gen 1 if pc boots in legacy bios, or gen 2 if uefi.

    Once installed, mount second vhd as a drive, and restore Macrium image overwriting clean installed version.

    Add boot entry for new vhd to enable it to boot on host..
      My Computer


  3. Posts : 3
    Windows 10 Pro x64
    Thread Starter
       #3

    cereberus said:
    Problem is your native vhd does not contain boot files. If you install it in vm first, then mount as vhd, you can add a boot entry.

    If you have apps etc in existing vhd, do this.

    Image backup C drive in current vhdx using Macrium Reflect Free.

    Clean install 17754 in Hyper-V using gen 1 if pc boots in legacy bios, or gen 2 if uefi.

    Once installed, mount second vhd as a drive, and restore Macrium image overwriting clean installed version.

    Add boot entry for new vhd to enable it to boot on host..
    Thanks for the suggestion.

    I created a new machine in hyper-v, tried to install the latest insider builds but it wouldn't boot from them either. Only 17134.1 iso worked. So I installed that instead to get the correct vhdx configuration. However it took 1hr20mins!

    Tried imaging using macrium, at this point I was fed up with waiting and the time element. Thought there must be an easier way.

    Checked the structure of 17134.1 vhdx created in hyper-v, it contained EFI, Windows and Recovery partitions.

    Remembered you stating something about my previous vhdx not having correct boot files.
    (17760 only contained windows partition, no EFI, MSR or Recovery)

    So created a new vhdx (A1) within disk manager, used diskpart following instructions on MSoft website as guidance and adapted to my configuration. https://docs.microsoft.com/en-us/win...ive-partitions

    Deployed .wim to the windows (W:) partition (A1) and applied bcdboot (from A1) to the EFI (S:) partition on the vhdx (A1). Attached this vhdx (A1) to vm in hyper-v and booted successfully (Tip, rename the EFI to something like "SystemVHD or SysVHD" to avoid confusion)

    https://docs.microsoft.com/en-us/win...-the-boot-menu

    However, I had an existing vhdx (A2) with build 17760 deployed using dism and installed apps that I wanted to keep then boot in hyper-v to perform the upgrade to 17763. Obviously couldn't create EFI partition since there was one main partition starting from the beginning of the vhdx (A2).

    So I created a new vhdx (A3), 1gb (disk management complains about minimum size for gpt drive), gpt, made EFI and MSR partitions, and while the build 17760 vhdx (A2) was mounted in explorer I used bcdboot (from 17760 vhdx (A2)) to write boot files to this recent EFI (S:)(A3).

    Ejected both drives, mounted the EFI vhdx (A3) as SCSI (0) and the 17760 vhdx (A2) as SCSI (1), made sure boot order was EFI (A3) first, 17760 (A2) second in the firmware section of vm properties and managed to boot successfully

    Insider upgrade using win update and also from attached iso both initiated and proceeded to install without error.

    Due to the slowness of VM I decided its much quicker to deploy wim to vhdx with each new build and go through setup process than inplace upgrade. Tried a few tweaks in VM to allocate more cores and RAM made a noticeable difference but performance still far below VHD native boot not to mention that I have had enough of hyper-v and VMs.

    Thanks again.
      My Computer

  4. cereberus's Avatar
    Posts : 11,344
    Windows10
       #4

    "However, I had an existing vhdx (A2) with build 17760 deployed using dism and installed apps that I wanted to keep then boot in hyper-v to perform the upgrade to 17763. Obviously couldn't create EFI partition since there was one main partition starting from the beginning of the vhdx (A2)."

    The EFI partition does not need to be at beginning. You could just have shrunk the C drive partition from disk management and placed the EFI after it.

    Equally, you could have used minitool partition wizard to shrink C drive and move it to right to create space for EFI at the front.
      My Computer


  5. Posts : 3
    Windows 10 Pro x64
    Thread Starter
       #5

    cereberus said:
    "However, I had an existing vhdx (A2) with build 17760 deployed using dism and installed apps that I wanted to keep then boot in hyper-v to perform the upgrade to 17763. Obviously couldn't create EFI partition since there was one main partition starting from the beginning of the vhdx (A2)."

    The EFI partition does not need to be at beginning. You could just have shrunk the C drive partition from disk management and placed the EFI after it.

    Equally, you could have used minitool partition wizard to shrink C drive and move it to right to create space for EFI at the front.
    Thanks for the correction! Makes the process even easier.
      My Computer

  6. Kari's Avatar
    Posts : 17,117
    Windows 10 Pro
       #6

    My way to upgrade Windows on native boot virtual hard disks:

    First, I always initialize VHDX files meant to be used in native boot as MBR, never using GPT. MBR formatted VHDX boots OK also on UEFI / GPT computers, no problems there.

    When I need to upgrade Windows, I create a new Generation 1 VM using the VHDX file as existing disk. I will not let this VM to connect to Internet, selecting "Not connected" in New Virtual Machine Wizard. This because Windows already on VHDX contains real physical drivers for the host devices; if the VM connects to Internet, Hyper-V tries to find those now non-exiting hardware devices, which makes Windows Update painfully slow when it works at all.

    I will then use UUPDump and UUPtoISO to make the Insider build ISO I need (tutorial), and add it to VM.

    First boot of VM must be done from ISO / virtual DVD. When region selection screen is shown, I press SHIFT + F10 to open Command Prompt, check which drive letter my Windows partition on VHDX has with DISKPART (at this point it is sometimes C, sometimes D), then create boot files with following command:

    C:\Windows\System32\bcdboot C:\Windows

    Or, in case DISKPART had shown that the Windows drive is currently D:, changing the drive letters:

    D:\Windows\System32\bcdboot D:\Windows

    That's it. Restart VM, Windows will now boot. Upgrade by starting Setup from ISO / virtual DVD. When done, delete the VM and boot your host to VHDX.

    I've never had any issues with this. No third party tools, nor additional partitions required.

    Kari
      My Computer



  7. Posts : 1
    Windows 10 Pro
       #7

    Kari said:
    My way to upgrade Windows on native boot virtual hard disks:

    First, I always initialize VHDX files meant to be used in native boot as MBR, never using GPT. MBR formatted VHDX boots OK also on UEFI / GPT computers, no problems there.

    ...

    That's it. Restart VM, Windows will now boot. Upgrade by starting Setup from ISO / virtual DVD. When done, delete the VM and boot your host to VHDX.

    I've never had any issues with this. No third party tools, nor additional partitions required.

    Kari
    Hello Kari,
    I did looked at your tutorial “Native boot Virtual Hard Disk - How to upgrade Windows” on tenforums wich is very interesting as I have been stuck with this issue but I couldn’t make it work.
    I tried both methods with on both the same issue.
    The issue seems to be that my vhdx disk is a GPT which boots fine natively but here when I try it doesn’t boot at all as a non UEFI file system.
    I then tried to create a EFI partition which allowed me to boot normally on hyper-v but without being able to update as seen as virtual like when I boot normally without hyper-v.
    I converted then my vhdx to MBR but then I got a black screen when launching with a constant CPU at 4%. So no way to boot even MBR with hyper-v.
    Now I’m really stuck. If you have any ideas of what I could try it’s more than welcome as I use my vhdx as a real computer so not easy to reinstall from scratch.
    Best Regards
    Greg

    - - - Updated - - -

    I finally converted my vhdx to MBR but then I got a blinking cursor when launching and got stuck whatever I tried in cmd line.
    So I created a new fat32 partition with boot records and I managed to boot on hyper-v.
    Reusing vhdx (native boot) in Hyper-V-screenshot-4-.png

    But it seems this way didn’t trick windows update and I got stuck again.
    Reusing vhdx (native boot) in Hyper-V-screenshot-3-.png
    If you have any ideas of what I could try it’s more than welcome

    - - - Updated - - -

    I read that you use this method to get insider preview builds installed. Could the fact i'm trying to install the latest official iso version from MediaCreationTool1909.exe be the problem here ?

    - - - Updated - - -

    Finally I got it working. The final touch was to change PortableOperatingSystem to 0 in regedit to allow installation.

    - - - Updated - - -

    In fact I said it too fast and got a new error !!!
    Reusing vhdx (native boot) in Hyper-V-screenshot-5-.png
      My Computer


  8. Posts : 1
    win10prox64
       #8

    Kari said:
    .....check which drive letter my Windows partition on VHDX has with DISKPART (at this point it is sometimes C, sometimes D),...
    Hi Kari,
    my problem is, that DISKPART only sees the ISO volume (as DVD-ROM) and does not the Windows volume in my configuration.
    I run the VM from another native boot VHDX than which I want to update with your method. Could this be the reason of invisible Windows volume? How can I resolve this issue?
    THX!
    Nil
      My Computer


 

Related Threads
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 03:39.
Find Us




Windows 10 Forums