If you are using Docker, you may be accumulating unused containers and images that take up disk space. Sometimes it’s good to perform some disk space clean up, especially if you have limited storage.
- Remove unused containers, images, and build cache
docker system prune -a
docker builder prune -a
- Shutdown WSL and verify that it’s not running. Use PowerShell.
wsl --shutdown
wsl -l -v
- Run
diskparton PowerShell. It will open another window. - Perform vdisk compaction. Without this, you won’t actually see the freed space on the host machine.
select vdisk file="C:\Users\YourUsername\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu-or-some-dir\LocalState\filename.vhdx"
attach vdisk readonly
compact vdisk
detach vdisk
exit