Published on

Shrink virtual disk on WSL

Authors

Since last year I'm using laptop with windows OS and using WSL. Unfortunately my SSD is small and need more space to install warzone lol. After clean up everything in Ubuntu WSL, the disk space not reduced at all. After googling, I found out that I need manually shrink the virtual disk.

Open windows terminal using administrator privilege then follow these command below.


_9
wsl --shutdown
_9
diskpart
_9
# open Diskpart in new window
_9
# replace this part with your target vhdx
_9
select vdisk file="%LOCALAPPDATA%\Docker\wsl\data\ext4.vhdx"
_9
attach vdisk readonly
_9
compact vdisk
_9
detach vdisk
_9
exit

If you are using ubuntu, find the *.vhdx files in %localappdata%\Packages\CanonicalGroup... which mean ... can be random string. The processing time depends on the size of virtual disk.