tocOn this page 8 sections
Hyper-V supports two virtual disk formats. You meet them when you build virtual machines, mount backup images and move servers between platforms. Both formats put an entire disk inside one file. They are not interchangeable, though, and picking the wrong one can cause trouble later. This guide explains how they differ, when each one is the right choice, and how to work with both from PowerShell on a Windows VPS.
What the Two Formats Are
VHD is the original format. It dates from the Virtual PC era and was carried into early Hyper-V. Its structure is simple: a footer that describes the disk, plus an allocation table for dynamic disks. Because it is simple, almost every virtualization and imaging tool can read it.
VHDX arrived with Windows Server 2012. It was designed for larger disks, modern storage hardware and better recovery after a crash. On current Windows Server releases, Hyper-V Manager uses VHDX by default when you create a new disk.
The Differences That Matter
Maximum size
A VHD can hold just under 2 TB. A VHDX can grow to 64 TB. If a data disk could ever approach 2 TB, VHD is not an option.
Resilience to power loss
VHDX keeps an internal log of changes to its own metadata. If the host crashes or loses power while the disk is growing, Windows can replay that log and keep the file consistent. VHD has no log, so an interrupted write to a dynamic VHD can corrupt it. This alone is a good reason to prefer VHDX for anything that runs continuously.
Sector sizes and alignment
VHD presents 512-byte sectors to the guest. VHDX can present 4 KB logical sectors and aligns its data to suit modern drives with large physical sectors. This helps performance on current storage, especially for dynamic disks.
Space reclamation
VHDX supports TRIM and UNMAP. When the guest deletes data, the host can be told those blocks are free. A dynamic VHDX can then shrink with Optimize-VHD more effectively than an old VHD can.
Generation 2 VMs and online resizing
Generation 2 virtual machines boot only from VHDX. Hyper-V can also resize a VHDX attached to a virtual SCSI controller while the VM is running. With VHD, you usually have to shut the VM down to resize the disk.
When VHD Still Makes Sense
VHDX is the better format in most cases. Keep VHD only when something downstream requires it:
- Legacy hosts: Hyper-V on Windows Server 2008 R2 and earlier cannot open VHDX files.
- Third-party tools: some older imaging, forensic or migration tools accept only VHD. Check the tool's documentation before you convert.
- Cloud uploads: some cloud platforms require VHD for imported images, and some require a fixed-size VHD. Check the target platform's current requirements.
Beyond these cases, choose VHDX.
Inspecting a Disk from PowerShell
Connect to your VPS over RDP and open an elevated PowerShell window. If the Hyper-V module is installed, Get-VHD shows the format, type and sector sizes:
Get-VHD -Path 'D:\VHD\data.vhdx' |
Select-Object VhdFormat, VhdType, Size, FileSize, LogicalSectorSize, PhysicalSectorSize
The Get-VHD, Convert-VHD, Resize-VHD and Optimize-VHD cmdlets come from the Hyper-V PowerShell module. That module depends on Hyper-V components, which may be unavailable inside a VPS that does not support nested virtualization. In that case, use the built-in storage tools below. They work without Hyper-V.
Mounting VHD and VHDX Without Hyper-V
Windows Server can attach either format as a local disk. This is useful for opening backup images or copying files out of an old server image:
Mount-DiskImage -ImagePath 'D:\Images\old-server.vhdx'
Get-DiskImage -ImagePath 'D:\Images\old-server.vhdx' | Get-Disk | Get-Partition
# When finished
Dismount-DiskImage -ImagePath 'D:\Images\old-server.vhdx'
Add -Access ReadOnly when you only need to read the image. This protects the original from accidental writes.
To create a new virtual disk without Hyper-V, use diskpart. The file extension you choose sets the format:
diskpart
create vdisk file="D:\VHD\scratch.vhdx" maximum=20480 type=expandable
attach vdisk
create partition primary
format fs=ntfs quick label=Scratch
assign letter=S
exit
A VHDX like this is a convenient container for portable data. You can detach it, back it up as a single file with something like rclone pushing it to cloud storage, and attach it again on another server.
Converting Between Formats
On a machine with the Hyper-V module, conversion takes one command. The source disk must not be in use, so shut down any VM attached to it first:
Convert-VHD -Path 'D:\VHD\legacy.vhd' -DestinationPath 'D:\VHD\legacy.vhdx' -VHDType Dynamic
The cmdlet writes a new file and leaves the original as it was. Keep the old VHD until the converted disk has booted or mounted correctly, then delete it. You will need free space for both files during the conversion. Converting in the other direction works the same way: give the destination a .vhd extension. This only works if the disk is smaller than the VHD limit.
After converting to VHDX, it is worth growing or shrinking the disk if needed:
Resize-VHD -Path 'D:\VHD\legacy.vhdx' -SizeBytes 200GB
Optimize-VHD -Path 'D:\VHD\legacy.vhdx' -Mode Full
Resizing the file does not resize the partition inside it. Extend the volume afterwards in Disk Management or with Resize-Partition inside the guest.
Moving Disks to Other Hypervisors
Both formats can be moved to other platforms. On a Linux host, qemu-img reads VHD (which it calls vpc) and VHDX, and converts them to qcow2 or raw for KVM-based platforms:
qemu-img convert -p -f vhdx -O qcow2 legacy.vhdx legacy.qcow2
For a full walkthrough of capturing a running Windows machine and bringing it up on KVM, see our guide on moving a live Windows server into Proxmox. If a migrated or newly attached disk causes the boot order to fail, the steps in fixing Windows when it won't boot after adding a second disk also apply to virtual disks.
Quick Recommendations
- Use VHDX for all new Hyper-V disks, data containers and Generation 2 VMs.
- Use dynamic VHDX for lab and test machines, and fixed VHDX where you need predictable performance and want to rule out running out of space.
- Keep VHD only for legacy hosts, tools that cannot read VHDX, or upload targets that require it.
- Always convert to a copy, test it, and only then remove the original.
Run this on your own Windows VPS
Get a Windows VPS from WindowsVPS in about 60 seconds, with full Administrator access over RDP, NVMe storage and the Windows license included.
Written by the WindowsVPS Team
We run Windows Server VPS hosting and write these guides from the same setups our customers use: RDP, PowerShell, trading terminals and always-on bots. Questions about a guide? Contact us.