guide · static export
PC · vhd

Boot a Second Windows From a VHD for Testing

Native VHD boot runs a complete Windows from a file on your existing disk. It isolates a test install without partitioning, and deleting one file removes it completely.

by@guidox updated:10/31/26 time:45 min level:Advanced tested on:Windows 11 24H2 works on:Windows 10, Windows 11, Windows Server 2019 tools:Command Prompt as administrator, A Windows ISO, Free disk space
TL;DR

Create a **VHDX**, apply an **install.wim** with **DISM**, then add a boot entry whose **device** and **osdevice** point at **vhd=[D:]\path**. Remove it by deleting the entry and the file.

Before you start

Requirements

  • A second disk or free space for 40 GB
  • A Windows ISO
  • Admin rights
  • 45 minutes
Step by step

Instructions

01

Create and attach the virtual disk

A dynamically expanding **VHDX** starts small and grows with use. Create it on a **data disk**, not on the system partition you are testing against.

New-Item -ItemType Directory D:\TestVHD -Force | Out-Null
New-VHD -Path D:\TestVHD\test.vhdx -SizeBytes 60GB -Dynamic
Mount-VHD -Path D:\TestVHD\test.vhdx
Get-Disk | Where-Object Location -like '*test.vhdx*' | Select-Object Number,Size,PartitionStyle
02

Partition and format it from diskpart

The new disk is uninitialised. One NTFS partition is enough, and the drive letter matters because the boot entry refers to it.

diskpart
select vdisk file="D:\TestVHD\test.vhdx"
select partition 1
format fs=ntfs quick label=TESTVHD
assign letter=V
exit
03

Apply a Windows image into it

**DISM /Apply-Image** writes the install image into the mounted volume. Take index 1 for the standard edition, and confirm the index list first.

Mount-DiskImage -ImagePath E:\ISO\Win11_24H2.iso
Get-WindowsImage -ImagePath F:\sources\install.wim | Select-Object ImageIndex,ImageName
DISM /Apply-Image /ImageFile:F:\sources\install.wim /Index:1 /ApplyDir:V:\
tip**/ApplyDir** needs the trailing backslash. Without it DISM writes into the parent directory and the image ends up in the wrong place.
04

Create the boot files and the entry

The system partition needs a boot manager entry that points at the VHD, not at the physical disk. **bcdedit /copy** clones the current entry, then two values repoint it.

bcdboot V:\Windows /s S: /f UEFI
bcdedit /copy {current} /d "Test VHD"
:: use the GUID printed above
bcdedit /set {GUID} device vhd=[D:]\TestVHD\test.vhdx
bcdedit /set {GUID} osdevice vhd=[D:]\TestVHD\test.vhdx
bcdedit /set {GUID} detecthal on
⚠ warningThe bracket form **vhd=[D:]\...** takes a drive letter and no colon inside. A wrong path produces a boot manager error without further explanation.
05

Boot it and confirm isolation

After the first boot, inside the VHD, the system disk is the VHD itself. Checking that proves the test install cannot damage the host installation.

bcdedit /enum | Select-String -Pattern 'description|device'
Get-Disk | Where-Object IsBoot -eq $true | Select-Object Number,FriendlyName,Location
Get-Volume C | Select-Object FileSystemLabel,DriveLetter
06

Remove it cleanly

Delete the boot entry first, then dismount and delete the file. Removing the file with the entry still present leaves a boot menu item that fails.

bcdedit /delete {GUID} /cleanup
Dismount-VHD -Path D:\TestVHD\test.vhdx
Remove-Item D:\TestVHD\test.vhdx -Force
bcdedit /enum | Select-String -Pattern 'description'
Troubleshooting

Common issues

The boot menu entry fails with 0xc000000f

The device path in bcdedit does not match the file. Compare the two values with the real path, and remember the bracket form without a colon.

Boot is extremely slow inside the VHD

Expected on a spinning disk or a nearly full host disk. Keep the VHDX on an SSD and reserve free space for its growth.

The test install cannot activate

Native VHD boot uses the host's digital licence when the edition matches. A different edition needs its own key or stays unactivated.

Windows Update breaks the VHD boot

Feature updates rewrite the boot configuration. Recreate the entry with bcdedit afterwards, or keep the test install on a generic image without feature updates.

FAQ

Frequently asked

Is this the same as Hyper-V?

No. The VHD install runs on real hardware with full performance; Hyper-V runs in a virtual machine. VHD boot is for testing an install, not for isolation from hardware.

Does it need Hyper-V installed?

Only for the New-VHD cmdlet. Diskpart can create the same file with no optional feature at all.

How to undo this

Delete the boot entry with bcdedit /delete {GUID} /cleanup, dismount the VHD and delete the file. The host installation was never modified.

Changelog · 1 entry
  1. 2026-10-31
    First version
Interactive version: checklist, feedback, related guides →

Free · no account needed · tracks your progress