Sorry for the slow response. I was not yet up and in front of my primary system
.
Below are my raw notes on this topic. You can, of course, alter things like the size of the recovery partition, drive letters used, etc. I have reasons for using the values I show in my notes, but feel free to use what works best for you.
If you have any questions on this procedure, do let me know.
DETAILED PROCEDURE
1) Create a VHD
NOTE: The commands below assume you are creating the VHD on F: and naming the VHD WIN11PRO.vhdx with a size of 100 GB, a recovery partition of 2GB, and drive letter W:. Modify the commands to fit your needs. While there are ways to install Windows to a VHD on a BitLocker encrypted drive, there are some special steps needed that we will not go into here. Avoid installing to a BitLocker encrypted drive for this procedure.
Run the following commands from an elevated command prompt:
diskpart
create vdisk file=F:\W11PRO.vhdx maximum=102400 type=expandable
attach vdisk
convert gpt
create partition efi size=260
format quick fs=fat32 label="System"
create partition msr size=128
create partition primary
shrink minimum=2048
format quick fs=ntfs label="Windows"
assign letter="W"
create partition primary
format quick fs=ntfs label="WinRE"
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
gpt attributes=0x8000000000000001
exit
2) Run the following commands to apply the image to the VHD:
Make sure to use the index number associated with the edition of Windows you want to install. To get a list of Windows editions on your media and the associated index number, run this command:
dism /Get-WimInfo /WimFile:I:\Sources\install.wim
Note that the path references the location of the install.wim file located in your mounted Windows image or a folder on your HDD.
Now, run these commands. The first line is long and may wrap in this document. It ends with
/applydir:W:\
. You can replace W: with another letter.
dism /apply-image /imagefile:I:\sources\install.wim /index:6 /applydir:W:\
bcdboot W:\Windows
bcdedit /set {default} description "Win11 PRO (VHDX)"
In the above commands we are making the virtual disk the default boot option. We do this to avoid premature boot to the primary OS. You can change this later.
We will now boot the instance of Windows in the VHD and allow setup to proceed, up to a point. Reboot the system. A menu showing the new VHD and your original primary Windows installation will be shown. Select the VHD or allow it to timeout to boot the VHD. Windows setup will run, and the system will reboot. Allow it to once again boot the VHD.
IMPORTANT: If you are installing the same edition of Windows 10 or 11 (Home, Pro, etc.) as is already installed and activated on this system, then this installation will also activate, and you will be able to fully personalize Windows. Note that this holds true even if your primary OS is Windows 10, but you are installing Windows 11 to the VHD. If Windows does not activate, you may need to select the option to troubleshoot activation, but it should then activate successfully. However, if you are installing a different edition of Windows, then you should make certain that you disable any Ethernet connection BEFORE you boot into this instance of Windows. If the system finds an Internet connection, you will lose the ability to perform many personalization tasks.