WSL is using too much disk space on Windows
Short answer: each WSL distribution lives in one virtual disk file, ext4.vhdx. It grows as you add files in Linux, but it does not shrink when you delete them, so Windows never gets that space back by itself.
Where the disk is
- Store installs:
%LocalAppData%\Packages\CanonicalGroupLimited…\LocalState\ext4.vhdx - Newer installs:
%LocalAppData%\wsl\{id}\ext4.vhdx - Docker Desktop keeps its own under
%LocalAppData%\Docker\wsl
By hand
- Clean up inside Linux first (old build output,
~/.cache). - Shut WSL down:
wsl --shutdown - Let the disk give space back by itself from now on:
wsl --manage <distro> --set-sparse true(recent WSL versions). The older ways,Optimize-VHDor diskpart'scompact vdisk, need administrator rights.
With Sparewise
- Lists every WSL and Docker disk with its size.
- Can switch a disk to sparse, after asking. It shuts WSL down first, so save your work in Linux windows.
- Never deletes a distribution. That is your call (
wsl --unregisterdeletes everything in it).