VHDX is so flexible now - multiple vhdx files within the same Virtual disk in a VM.


jimbo45

Well-known member
Pro User
VIP
Local time
8:10 AM
Posts
4,000
Location
Hafnarfjörður IS
OS
Windows XP,7,10,11 Linux Arch Linux
Hi folks
I don't think Ms made enough in publishing the huge improvement of the flexiblity of being able to use VHDX files on external devices for installing and running windows and even within a VM itself.

Here within a single VM I have 2 vhdx files and can boot up either Windows 22 Server or Windows 11. I'm running on a smallish Linux laptop with KVM/QEMU but the process should work on a Windows host too.

On your main Virtual Disk Create 1 EFI file (100mb fat32) and 2 bog standard windows vdisk files. Then from command line --stand alone macrium, winpe or whatever select each vdisk in turn, attach it, install windows and then run the bootloader to the EFI partition.

Now when you start your VM you should get something like this :

Screenshot_20220929_113240.png

Cheers
jimbo
 

My Computer

System One

  • OS
    Windows XP,7,10,11 Linux Arch Linux
    Computer type
    PC/Desktop
    CPU
    2 X Intel i7
Hi folks
I don't think Ms made enough in publishing the huge improvement of the flexiblity of being able to use VHDX files on external devices for installing and running windows and even within a VM itself.

Here within a single VM I have 2 vhdx files and can boot up either Windows 22 Server or Windows 11. I'm running on a smallish Linux laptop with KVM/QEMU but the process should work on a Windows host too.

On your main Virtual Disk Create 1 EFI file (100mb fat32) and 2 bog standard windows vdisk files. Then from command line --stand alone macrium, winpe or whatever select each vdisk in turn, attach it, install windows and then run the bootloader to the EFI partition.

Now when you start your VM you should get something like this :

View attachment 40772

Cheers
jimbo
There is nothing new here - I have been doing this for years since early Windows 10 days in Hyper-V. I bet some of our guru guys have been doing it since Windows 8 days.

It is kind of obvious a user clicks that the vm is essentially a virtual motherboard, and like any real pc, you can attach as many hard drives as you can (PC is limited by number of slots). The bcd works in same way.

Even if you only have one physical drive, you can partition drive as well. You can partition vhdx's as well but rather pointless as no (practical) limit as to how many vhdx's that can be attached to a vm.

No if you want real fun, you can nest vms. I once ran a W10 hyper-v instance from a kvm vm windows installation, and inside the W10 hyper-v installation, I ran a nested hyper-v instance i.e. 3 levels of vm.

Of course, the only reason real to do this is "because you can" LOL. It ran like a dog!
 

My Computer

System One

  • OS
    Windows 10 Pro + others in VHDs
    Computer type
    Laptop
    Manufacturer/Model
    ASUS Vivobook 14
    CPU
    I7
    Motherboard
    Yep, Laptop has one.
    Memory
    16 GB
    Graphics Card(s)
    Integrated Intel Iris XE
    Sound Card
    Realtek built in
    Monitor(s) Displays
    N/A
    Screen Resolution
    1920x1080
    Hard Drives
    1 TB Optane NVME SSD, 1 TB NVME SSD
    PSU
    Yep, got one
    Case
    Yep, got one
    Cooling
    Stella Artois
    Keyboard
    Built in
    Mouse
    Bluetooth , wired
    Internet Speed
    72 Mb/s :-(
    Browser
    Edge mostly
    Antivirus
    Defender
    Other Info
    TPM 2.0
, install windows and then run the bootloader to the EFI partition.
Can you explain this bit please? I'm still learning this stuff.

On a side note how do you backup your vhdx based systems? Just use a dedicated backup solution? Copy the vhdx file while off-line?
 

My Computer

System One

  • OS
    Windows 11, Windows 10
Can you explain this bit please? I'm still learning this stuff.

On a side note how do you backup your vhdx based systems? Just use a dedicated backup solution? Copy the vhdx file while off-line?
What @Jimbo is describing is how to boot multiple vhdx files from one VM.

You can just have multiple blank vhdx's attached to a VM, and install windows in each vhdx file in turn and you would not even need to do any bcdedits. The problem with this is all boot files are on the efi partition on first vhdx file. This may be the easiest way to do it, but problem is if you decide to boot any of the vhdx files in a separate vm, it will not boot as it will not have an EFI partition.

This is identical to what happens on a physical pc if you install a second version of windows on a second drive without removing the original drive first. This is quite a common "rookie" error where a user reinstalls windows on an ssd, but did not remove the hard drive first, and the EFI file is still on the hdd. When the hdd is removed, the ssd will not boot as it does not have an efi partition.

If you set up each vhdx in isolation from others, each will have their own efi partitions and all you need to do is run bcd edits so the boot files are copied to first vhdx file enabling you to select each from boot menu.

To boot multiple vhdx files from a vm, such that each vhdx can be booted standalone as well), the way I recommend is as follows. It is slighty longer to do, but not by much as most of the time is in installing to each vhdx file.

1) Create a new vm (or use existing activated and install windows into a vhdx files in normal way (see tutorial section). Use the version of Windows you intend to be the main OS you will use in the vm)

2) create a new vm for each OS you want to have in a single vm. (You can do this with original vm detaching existing vhdx and adding new one in turn but easy to lose track).


It does not matter if the new vms are unactivated - they are only temporary vms to make sure each windows version is set up right.

3) delete all temporary vms but vm in step 1 from Hyper-V (do not delete the vhdx files).

4) attach each vhdx to vm in step 1.

5) run hyper-v and it will boot to OS in step 1.

6) you will see each vhdx with windows and a drive letter say E: for second windows version

7) open admin command prompt and type

bcdboot e:\windows /p /d

8) repeat for each VHDX version

You will now have a boot menu in vm for multiple vhdx files.

If you do it like above, each vhdx can be attached standalone to another vm if you prefer. The crucial point above is that each vhdx is installed individually without other vhdxs being present, and each vhdx contains its own boot files.

Re. backup - You can use any method - I just copy them. If space is an issue, you can use any tool that compresses them - even winzip.


Note: if you want to have multiple versions of same installation e.g. 2 versions of windows 10 Pro, you can simply copy the vhdx of first installation rather than installing to a second vhdx. You could do this to practice the steps above, so you get hang of it.
 

My Computer

System One

  • OS
    Windows 10 Pro + others in VHDs
    Computer type
    Laptop
    Manufacturer/Model
    ASUS Vivobook 14
    CPU
    I7
    Motherboard
    Yep, Laptop has one.
    Memory
    16 GB
    Graphics Card(s)
    Integrated Intel Iris XE
    Sound Card
    Realtek built in
    Monitor(s) Displays
    N/A
    Screen Resolution
    1920x1080
    Hard Drives
    1 TB Optane NVME SSD, 1 TB NVME SSD
    PSU
    Yep, got one
    Case
    Yep, got one
    Cooling
    Stella Artois
    Keyboard
    Built in
    Mouse
    Bluetooth , wired
    Internet Speed
    72 Mb/s :-(
    Browser
    Edge mostly
    Antivirus
    Defender
    Other Info
    TPM 2.0
What @Jimbo is describing is how to boot multiple vhdx files from one VM.........

Sorry I understand most of that. I was wondering about:
and then run the bootloader to the EFI partition
If I was starting from a blank disk how do I initialise the bootloader on the efi partition?


I was wondering about system backups because realising copying a vhdx file while in use probably wouldn't go too well, and not wanting to install dedicated system backup software yet thought about using VSS. I wrote a batch script that calls a tool which creates a volume shadow and copy's the "online" vhdx from that. I copy it and overwrite a second vhdx which also has a boot entry. Basically works like an online system backup but where I can quickly boot into the backup if anything goes wrong in the main system.

Does this sound like a good idea?
 

My Computer

System One

  • OS
    Windows 11, Windows 10
1. The installer sorts out efi setup for each vm.

2) you only need bcdboot to link undividual vhdxs to boot menu tying to a single efi in first drive.

3) Far too complicated. .Just shutdown vm, copy file
 

My Computer

System One

  • OS
    Windows 10 Pro + others in VHDs
    Computer type
    Laptop
    Manufacturer/Model
    ASUS Vivobook 14
    CPU
    I7
    Motherboard
    Yep, Laptop has one.
    Memory
    16 GB
    Graphics Card(s)
    Integrated Intel Iris XE
    Sound Card
    Realtek built in
    Monitor(s) Displays
    N/A
    Screen Resolution
    1920x1080
    Hard Drives
    1 TB Optane NVME SSD, 1 TB NVME SSD
    PSU
    Yep, got one
    Case
    Yep, got one
    Cooling
    Stella Artois
    Keyboard
    Built in
    Mouse
    Bluetooth , wired
    Internet Speed
    72 Mb/s :-(
    Browser
    Edge mostly
    Antivirus
    Defender
    Other Info
    TPM 2.0
Back
Top Bottom