What a VHDX is and why you have one
VHDX is Windows' virtual disk format — the successor to VHD, with a 64 TB ceiling and resilience against power loss — and inside it lives a complete filesystem that Windows mounts like a real drive. You probably didn't create it on purpose: WSL2 keeps every Linux distro in an ext4.vhdx, Docker Desktop stacks its images on top of those, Dev Drive is a mounted VHDX by design, and Hyper-V VMs and some backup tools add their own. Search your disk for *.vhdx and you'll likely find more than one.
- WSL2 distros: ext4.vhdx under %LOCALAPPDATA%\Packages\...\LocalState — invisible to df inside Linux
- Docker Desktop: its WSL data disk grows with every pulled image and container layer
- Dev Drive: a mounted VHDX that's supposed to be there — check real usage before judging
- Hyper-V VMs: under the default Hyper-V folder or wherever you created the VM
- Backup and "rescue" images from imaging tools — the 40 GB surprise in the root of C:\
The growth problem: expands on demand, never shrinks
Dynamic VHDX files grow when data is written but don't shrink when it's deleted: the space is marked free inside the guest filesystem while the host file stays at its high-water mark. A WSL2 distro where you pulled containers, built kernels and deleted everything can still hold a 60 GB ext4.vhdx with 12 GB of actual data — Linux says it's empty, Windows says it's huge, and both are right. This isn't a leak; it's the design, and it means every "clean up inside WSL" session returns nothing to C: until you compact the file itself.
How to reclaim the space safely
For WSL2: run wsl --shutdown first, then either wsl --manage <distro> --set-sparse true on recent builds or the export/import routine — export to a .tar, unregister, import back, and the fresh vhdx matches the real data size. For Docker Desktop, prune images and volumes inside Docker before shrinking its data disk, or you'll compact the same file again next week. Hyper-V VMs compact from Hyper-V Manager (or Optimize-VHD -Path <file> -Mode Full) with the VM off, and dev drives just need a reality check: mount it, look at actual usage, resize only with a plan. And the one rule that matters: never delete a .vhdx you can't identify — if a VM or distro you still use points at it, you've just deleted its whole disk.
Questions and Answers
Is it safe to delete a VHDX file?
Only if you know what owns it. An orphaned backup image or the leftover disk of a removed WSL distro is fair game; deleting a live VM's or Docker's VHDX destroys its data on the host.
Why is my WSL2 virtual disk so big?
Dynamic VHDX files grow on demand but never shrink automatically — deleting files inside Linux doesn't return space to Windows. Compact it with wsl --manage --set-sparse or export/import the distro.
Know what is included before you buy.
The one-time 30-minute trial covers core tools. PRO-labelled features stay locked until a paid license is activated.
Read next
Write to us: [email protected]