Shink virtual disks

06 May 2022

docker how to vhd wsl

Repost of Stack Overflow answer
It came handy when I was trying to free some disk space from the local docker instance

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

Maybe someday there will be more elegant way to do it: WSL GitHub Issue


Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.