Creating a Bootable VHDX with Windows
This guide walks you through creating a Virtual Hard Disk (VHDX) with a Windows installation that can be booted directly. This is useful for setting up test environments, backups, or portable Windows installations.
Prerequisites
- A Windows installation file in
.wim
format (such asinstall.wim
from Windows installation media). - Administrator privileges on your machine.
Steps to Create a Bootable VHDX
1. Create the VHDX Using Diskpart
Open Diskpart and follow these commands to create a fixed-size VHDX, attach it, and prepare it with a primary partition.
# Open Diskpartdiskpart
# Create a VHDX with a size of 25 GBcreate vdisk file=C:\windows.vhdx maximum=25600 type=fixed
# Attach the VHDXattach vdisk
# Create a partition for the Windows files, format it, and assign it a drive lettercreate partition primaryformat quick label=vhdxassign letter=v
# Exit Diskpartexit
2. Apply the Windows Image to the VHDX
Use the Deployment Image Servicing and Management (DISM) tool to apply the Windows image to your newly created VHDX.
# Get the index of the Windows installation that you want to deploydism /Get-WimInfo /WimFile:install.wim
# Apply the WIM file with the correct index (replace `index` as needed)dism /Apply-Image /ImageFile:install.wim /index:1 /ApplyDir:V:\
3. Add a Boot Entry
To boot from the VHDX, add a new boot entry using the bcdboot
command.
# Add boot entry for the new VHDbcdboot V:\Windows /d
4. Verify the Boot Configuration
Finally, confirm that the boot entry was successfully added and is properly configured by using the bcdedit
command.
# List all boot entries to verify the new entrybcdedit /enum all
Additional Information
- BIOS/UEFI Configuration: Ensure your system’s BIOS or UEFI settings support booting from virtual hard disks if necessary.
- Troubleshooting: If the boot entry does not work as expected, try reviewing the output from the
bcdedit
command to confirm the entry is correct.