Resize Docker (Link)
Turns out there is a way to shrink the vhdx images properly in windows:
- Run in cmd:
docker system prune
(optional--all
), to clean up disk space - Right mouse click on docker desktop in system tray -> quit
- Run in cmd:
wsl --shutdown
- Run
Optimize-VHD -Path "$env:LOCALAPPDATA\Docker\wsl\data\ext4.vhdx" -Mode Full
, this will resize the vhdx images Same way you can try to find vhdx images that utilize too much space and optimize them as well. You can use TreeSize(Bing it: Tree Size Windows) to find which image takes the most of the space and optimize them.
P.S. dont forget to run docker system prune
Resize WSL2 (Link)
When the command let optimize-vhd
is not available in your system do the following:
wsl --shutdown
select vdisk file="C:\Users\%username%\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx"
attach vdisk readonly
compact vdisk
detach vdisk
diskpart /s <SAVED_SCRIPT_FOLDER_PATH>\compact-disk.txt