Clear WSL2 Disk Space - Optimize-VHD

PHOTO EMBED

Mon Dec 27 2021 12:25:33 GMT+0000 (Coordinated Universal Time)

Saved by @RokoMetek #bash #powershell

wsl --shutdown
diskpart
# open window Diskpart
select vdisk file="C:\WSL-Distros\…\ext4.vhdx"
attach vdisk readonly
compact vdisk
detach vdisk
exit
content_copyCOPY

Windows Path to ext4.vhdx wsl ubunut A1. Open up regedit.exe and input the following into the address bar, hit enter to see such details: Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss Under Lxss you should find all your WSL distro entries and and the BasePath key should give you the folder that a given distro's virtual drive file exists within.

https://github.com/microsoft/WSL/issues/4699#issuecomment-627133168