Partitions used by the WSL distro on Windows are dynamically extended when you need more space for them. Unfortunately it doesn't work the othey way round. Ie. when you clean them up (by removing node_module
folders from your experimental repos ;) ) Windows will not scale them down and you'll wonder where did all of the space go.
Fortunately there's a way to do it yourself.
- Shutdown the WSL. (You may also need to to shutdown the Docker Desktop which will try to restart the WSL.)
wsl.exe --shutdown
- Call Optimize-VHD commandlet pointing it to the file representing the WSL partition on windows file system.
Optimize-VHD -Path %PROFILE%\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx -Mode Full
If you want to check how much space the distro uses atm:
wsl.exe --system -d Ubuntu df -h /mnt/wslg/distro
Cheers!
Bibliography