WSL Ubuntu Reclaim Space on Vdisk Image Using Diskpart in Windows

Possible Disk Image locations

%userprofile%\AppData\Local\Packages
%userprofile%\AppData\Local\Docker\wsl

If using Docker Desktop, exit the program and shutdown WSL(use terminate if wsl starts up again automatically), check nothing is running

wsl --shutdown
wsl --terminate [Name]
wsl --list --verbose

Start Diskpart with elevated privileges

diskpart

Attach the image file and compress the image

select vdisk file=[path to image file]\ext4.vhdx
attach vdisk readonly
compact vdisk
detach vdisk
exit

Leave a Reply

Your email address will not be published. Required fields are marked *