Prerequisites
There are mainly three ways to create a VHDX on Windows.
| Method | Use case |
|---|---|
| Disk Management GUI | Easy manual creation |
| PowerShell / Hyper-V module | Suitable for automation and creating differencing VHDXs |
| DiskPart | Create using the standard Windows CLI; Hyper-V module not required |
When creating a differencing VHDX, the easiest method is usually to use PowerShell’s New-VHD -Differencing. Microsoft’s official documentation also includes an example for creating a differencing VHDX: New-VHD -ParentPath c:\Base.vhdx -Path c:\Diff.vhdx -Differencing. (Microsoft Learn)
1. How to Create a Regular VHDX
Method A: Create with the “Disk Management” GUI
Win + X- Open Disk Management
- From the menu, select Action → Create VHD
- Specify the following:
- Location:
C:\VHD\Base.vhdx - Size: for example,
64 GB - Format: VHDX
-
Type:
- Fixed size: Allocates the full capacity from the beginning. Prioritizes performance and stability.
-
Dynamically expanding: The file grows according to usage. Suitable for saving space.
- After creation, it is added to the disk list
- Right-click and select Initialize Disk
- Select GPT or MBR
-
Usually, choose GPT
- Right-click the unallocated space
- Select New Simple Volume
- Format it as NTFS or another file system
Method B: Create a VHDX with PowerShell
Run this in PowerShell with administrator privileges.
Create a dynamically expanding VHDX
New-VHD -Path "C:\VHD\Base.vhdx" -SizeBytes 64GB -Dynamic
Create a fixed-size VHDX
New-VHD -Path "C:\VHD\Base.vhdx" -SizeBytes 64GB -Fixed
New-VHD is a Hyper-V PowerShell cmdlet that creates a virtual hard disk. Microsoft’s Hyper-V module also includes New-VHD. (Microsoft Learn)
The following is an example of mounting the created VHDX, initializing it, and formatting it.
Mount-VHD -Path "C:\VHD\Base.vhdx"
$disk = Get-Disk | Where-Object PartitionStyle -eq "RAW" | Sort-Object Number -Descending | Select-Object -First 1
Initialize-Disk -Number $disk.Number -PartitionStyle GPT
New-Partition -DiskNumber $disk.Number -UseMaximumSize -DriveLetter V |
Format-Volume -FileSystem NTFS -NewFileSystemLabel "BaseVHDX" -Confirm:$false
Method C: Create a VHDX with DiskPart
You can create one using the standard Windows diskpart tool without using the Hyper-V PowerShell module. Microsoft’s DiskPart reference explains that create vdisk creates a virtual hard disk and that immediately after creation it is in the same state as an uninitialized disk. (Microsoft Learn)
Run this in Command Prompt with administrator privileges.
diskpart
Run the following inside DiskPart.
create vdisk file="C:\VHD\Base.vhdx" maximum=65536 type=expandable
select vdisk file="C:\VHD\Base.vhdx"
attach vdisk
create partition primary
format fs=ntfs quick label="BaseVHDX"
assign letter=V
exit
Key point:
maximum=65536
is specified in MB, so 65536 MB = 64 GB.
type=expandable
means dynamically expanding. To create a fixed-size disk, use the following.
create vdisk file="C:\VHD\Base.vhdx" maximum=65536 type=fixed
attach vdisk is the command that mounts a VHD/VHDX and displays it as a local disk. (Microsoft Learn)
2. How to Create a Differencing VHDX Based on Another VHDX
Concept of a differencing VHDX
A differencing VHDX uses a parent VHDX as the read source and stores only the changes in the child VHDX.
Base.vhdx ← Parent disk. Base image
└─ Diff01.vhdx ← Child disk. Stores only changes
For example, it is suitable for the following uses.
- Quickly clone verification environments
- Keep a clean OS image as the parent
- Create multiple test environments with a small amount of storage
- If something breaks, you can return to the original state by deleting only the differencing VHDX
Important notes
Before creating a differencing VHDX, you must observe the following regarding the parent VHDX.
| Note | Reason |
|---|---|
| Do not modify the parent VHDX | Consistency with the child VHDX may break |
| Do not carelessly move the parent VHDX location | The child VHDX may no longer be able to find the parent |
| Do not delete the parent VHDX | The child VHDX becomes unusable |
| Setting the parent VHDX to read-only is safer | Prevents accidental updates |
| Do not make the differencing chain too deep | Causes performance degradation and management complexity |
Example of protecting the parent VHDX:
Set-ItemProperty -Path "C:\VHD\Base.vhdx" -Name IsReadOnly -Value $true
To解除する:
Set-ItemProperty -Path "C:\VHD\Base.vhdx" -Name IsReadOnly -Value $false
3. Create a Differencing VHDX with PowerShell
Basic command
New-VHD `
-ParentPath "C:\VHD\Base.vhdx" `
-Path "C:\VHD\Diff01.vhdx" `
-Differencing
Microsoft’s official documentation also shows an example where the parent VHDX is specified with -ParentPath, the differencing VHDX to create is specified with -Path, and -Differencing is specified. (Microsoft Learn)
Mount after creation
Mount-VHD -Path "C:\VHD\Diff01.vhdx"
Once mounted, it appears to Windows like a normal disk.
However, because a differencing VHDX is based on the contents of the parent VHDX, the parent side usually already has partitions and a file system. In that case, initialization and formatting are not required.
Dismount a differencing VHDX
Dismount-VHD -Path "C:\VHD\Diff01.vhdx"
4. Practical Example Using a Differencing VHDX
Example: Create a test environment from a base OS image
# Parent VHDX
$parent = "D:\VHD\BaseWindows.vhdx"
# Differencing VHDX
$child = "D:\VHD\Test01.vhdx"
# Create differencing disk
New-VHD -ParentPath $parent -Path $child -Differencing
# Mount
Mount-VHD -Path $child
To create multiple disks:
New-VHD -ParentPath "D:\VHD\BaseWindows.vhdx" -Path "D:\VHD\Test01.vhdx" -Differencing
New-VHD -ParentPath "D:\VHD\BaseWindows.vhdx" -Path "D:\VHD\Test02.vhdx" -Differencing
New-VHD -ParentPath "D:\VHD\BaseWindows.vhdx" -Path "D:\VHD\Test03.vhdx" -Differencing
The configuration looks like this.
BaseWindows.vhdx
├─ Test01.vhdx
├─ Test02.vhdx
└─ Test03.vhdx
Each differencing VHDX has its own independent changes.
5. Check and Modify the Parent Path of a Differencing VHDX
If you move the parent VHDX location, the child VHDX may no longer be able to find the parent.
In that case, you can set the parent path with Set-VHD -ParentPath. Microsoft’s Set-VHD documentation describes the -ParentPath parameter, which specifies the path of the parent disk for a differencing VHD. (Microsoft Learn)
Set-VHD `
-Path "C:\VHD\Diff01.vhdx" `
-ParentPath "D:\VHD\Base.vhdx"
6. Merge a Differencing VHDX into the Parent VHDX
If you want to merge the contents of a differencing VHDX into the parent or another differencing disk, use Merge-VHD. Microsoft explains that Merge-VHD is a cmdlet that merges virtual hard disks in a differencing VHD chain. (Microsoft Learn)
Example:
Merge-VHD -Path "C:\VHD\Diff01.vhdx" -DestinationPath "C:\VHD\Base.vhdx"
However, merging directly into the parent VHDX changes the base image. If you want to maintain a clean base, it is safer to take a backup before merging or convert it to another file.
7. Minimal Command Summary
Create a regular VHDX
New-VHD -Path "C:\VHD\Base.vhdx" -SizeBytes 64GB -Dynamic
Mount
Mount-VHD -Path "C:\VHD\Base.vhdx"
Create a differencing VHDX
New-VHD -ParentPath "C:\VHD\Base.vhdx" -Path "C:\VHD\Diff01.vhdx" -Differencing
Mount a differencing VHDX
Mount-VHD -Path "C:\VHD\Diff01.vhdx"
Dismount
Dismount-VHD -Path "C:\VHD\Diff01.vhdx"
Recommended operation
For verification purposes, the following configuration is easy to handle.
D:\VHD\
├─ Base\
│ └─ WindowsBase.vhdx ← Read-only
└─ Diff\
├─ Lab01.vhdx
├─ Lab02.vhdx
└─ Lab03.vhdx
After completing the parent VHDX, set it to read-only, and perform all experiments on the differencing VHDX side for safer operation.
Top comments (0)