Clean the disk usage of the .vhdx file of WSL

less than 1 minute read

Published:

Clean the disk usage of the .vhdx file of WSL

In short, use this opensource tool on GitHub:

Check your distro’s name with

wsl -l

And then use the tool with (replace “Your Distro Name” with the name in previous step)

wslcompact -c "Your Distro Name"

What happended here?

In the WslCompact.psm1 line 96:

` cmd /c “wsl –export ““$wsl_distro”” - | wsl –import wslcompact ““$tmp_folder”” -“ `

So this makes use of the ex-inporting, which will automatically compact the free disk usage.