Minimalist

Solves problems. Makes things work.

Archives

Compress VDISK for WSL2 Instance in DISKPART

In powershell:

wsl.exe --list --verbose

If the WSL in question is running, stop it, e.g.:

wsl.exe --terminate 'Ubuntu'

Locate the package directory for your WSL2 instance in your user folder in \AppData\Local\Packages\. Look for the vendor:

  • WhitewaterFoundryLtd.Co for Pengwin
  • CanonicalGroupLimited for Ubuntu
  • TheDebianProject for Debian
  • etc

The VHDX is in the LocalState subdirectory.

Then in DISKPART:

DISKPART> select vdisk file="C:\Users\kk\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState\ext4.vhdx"

DiskPart successfully selected the virtual disk file.

DISKPART> compact vdisk

  100 percent completed

DiskPart successfully compacted the virtual disk file.	
4d696e69-6d61-6c69-7374-2c20496e632e0000
Copyright © 1997-2023 Kurt Koller ("Minimalist")