WSL disk space not freed after deleting files? Check df and VHDX
- Published: 2026.10.23
- Updated: 2026.10.23
- Infrastructure Windows
You delete large files inside WSL, but the Windows drive still looks almost as full as before. Meanwhile, Linux reports more free space. Those two results can coexist because they describe different layers of storage.
WSL 2 normally stores a distribution’s Linux files in an ext4.vhdx virtual disk on Windows. Linux filesystem usage, the length of that VHDX file, and free space on the Windows drive are separate measurements. A few read-only checks help establish which one is causing the problem before you consider changing the virtual disk.
Identify the distribution
In Windows PowerShell, list the registered distributions and their WSL execution versions.
wsl --list --verbose
A 2 in the VERSION column identifies a WSL 2 distribution using a virtual disk. This is separate from a WSL product version such as 3.x. If you have several Ubuntu registrations, open the Linux terminal for the one you want to inspect before running the next commands.
Read Linux filesystem usage
df -h /
For the root filesystem, Size describes its capacity, Used describes occupied space, and Avail describes space available to Linux. A WSL 2 filesystem can report a large capacity because its virtual disk can grow. Its Size or Avail figure may therefore exceed the free space on the physical Windows drive without indicating a broken display.
For example, hundreds of gigabytes shown as available inside Linux do not mean that Windows has that much free storage. If the drive holding the VHDX runs short, new writes can encounter problems even while the Linux figures appear comfortable.
To inspect a particular project, open its directory in the Linux terminal and run:
du -sh -- .
The dot means the current directory. The command walks that directory’s contents, so a project with many files can take time to inspect. Permission errors mean some items were not counted; the reported figure is then incomplete. Remember that df describes a filesystem while du totals the directory you selected. Their numbers need not match.
Locate the VHDX on Windows
Return to Windows PowerShell. Replace Ubuntu in this example with the exact registration name from your list. The script reads the registered storage path and displays information about its standard ext4.vhdx file.
$Distro = 'Ubuntu'
$Registration = @(Get-ChildItem 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss' |
Where-Object { $_.GetValue('DistributionName') -eq $Distro })
if ($Registration.Count -ne 1) { throw 'Check the distribution name.' }
$VhdPath = Join-Path $Registration[0].GetValue('BasePath') 'ext4.vhdx'
Get-Item -LiteralPath $VhdPath -ErrorAction Stop |
Select-Object FullName, @{Name='LengthGiB';Expression={[math]::Round($_.Length / 1GB, 2)}}
FullName is the VHDX path. LengthGiB converts the file’s Length to gibibytes. It is neither the virtual disk’s maximum capacity nor Linux’s Used value. Sparse-file or compression behavior can also make file length differ from the space physically allocated on Windows. Compare the free space of the Windows drive holding that file separately.
If the script asks you to check the distribution name, compare the name with the registration list. If the file cannot be found, check the actual disk name and how that distribution was registered. Microsoft’s example assumes the standard ext4.vhdx name. Deleting or editing the file directly to free space can destroy the Linux environment it contains.
Compare the measurements after deletion
| Measurement | What it describes | What it does not establish |
|---|---|---|
| df Used / Avail | Usage and available space inside the Linux filesystem | Free space on the Windows drive |
| du total | Usage within the selected directory | The whole Linux filesystem or VHDX file length |
| VHDX Length | The file’s length on Windows | Its maximum virtual capacity or physical allocation |
With a dynamically expanding virtual disk, deleting Linux files does not necessarily shrink the VHDX file at the same moment. If df shows lower Used and higher Avail values, space is available for reuse inside Linux. Returning capacity to the Windows drive is a separate step in storage management.
Sparse-file behavior and space-reclamation settings can affect the result, so do not assume that every deletion returns the same amount to Windows. Microsoft’s sparseVhd setting makes newly created VHDs sparse; it does not mean that all existing disks have automatically changed.
For a useful before-and-after comparison, keep the distribution, VHDX, and Windows drive the same. Comparing different registrations or drives can make an unrelated change look like a reclamation result.
Prepare recovery before changing the disk
If Linux has enough free space but Windows does not, reclaiming virtual-disk space may be worth investigating. Microsoft’s compact vdisk documentation requires a dynamically expanding disk that is detached or attached read-only. That is a prerequisite to evaluate, rather than a procedure to apply directly to a running WSL environment. Choose a method appropriate to your WSL version and disk state.
Before making disk changes, a WSL backup restored under another name helps you check that recovery is possible. Moving the distribution to another Windows drive is another option when its current drive is too small. If slow file operations are the main concern, choosing a location for the project files addresses a different part of the problem.
References
-
Previous article
chmod does not change WSL permissions? Check metadata and storage 2026.10.22
-
Next article
systemctl fails in WSL? Check PID 1 and systemd 2026.10.23