How to reclaim the space used by WSL2's ext4.vhdx
After the release of the latest WSL2, I found it doesn't support GPU access, so I uninstalled the Ubuntu Distro and WSL2, but it leaves the following file behind which is over 7GB:
%LocalAppData%\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx
What is the proper way to remove this file and all relative components?
- I tried to delete it directly, but I'm unsure whether it's the correct way since it doesn't solve the problem, as the file and its folder are still there:
wsl --shutdown diskpart select vdisk file="C:\WSL-Distros\…\ext4.vhdx" attach vdisk readonly compact vdisk detach vdisk exit
If for example you installed Ubuntu from Windows Update is as simple as right click in the Start Menu Ubuntu tile -> Uninstall. If it still remains then open an elevated cmd and run wsl.exe --unregister Ubuntu