Ask

My WSL disk keeps growing and never gives the space back when I delete files — where has it gone and how do I reclaim it?

For question 3 there is now a proper answer rather than a maintenance ritual: sparse mode.

wsl --shutdown
wsl --manage <distro> --set-sparse true

With that on, the disk reclaims space as you delete, instead of only at the high-water mark. It is the setting you want on a laptop that builds containers, which from your description is you.

Two honest caveats. There is a small performance cost, because the disk has to do the bookkeeping as it goes — most people never notice it, but it is not free. And it applies per distro, so if you have several you set it on each.

Check wsl --help on your build for the exact spelling; this area has changed more than once and the flags moved.

1 · in/linux-on-windows ·

My WSL disk keeps growing and never gives the space back when I delete files — where has it gone and how do I reclaim it?

Worth adding: if the distro was installed through the Store the path is under Packages, but a distro imported with wsl --import sits wherever you put it. wsl --list --verbose plus a search for ext4.vhdx finds it if the usual path is not there.

And back up before the first time you do this. The procedure is safe and well documented, but it is still a raw operation on the disk holding all your work.

14 · in/linux-on-windows ·