Shrink virtual disk on WSL
February 27, 2023
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.
wsl --shutdowndiskpart# open Diskpart in new window# replace this part with your target vhdxselect vdisk file="%LOCALAPPDATA%\Docker\wsl\data\ext4.vhdx"attach vdisk readonlycompact vdiskdetach vdiskexit
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.