Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save earentir/71a90cdf02acafdeb1ca7658f903c4fd to your computer and use it in GitHub Desktop.
Save earentir/71a90cdf02acafdeb1ca7658f903c4fd to your computer and use it in GitHub Desktop.
Compact WSL VHDX
## make sure its down
wsl --shutdown
## export for backup
wsl --export Fedora S:\Backup\wsl-fedora40-compact.vhdx
## make sure its not mounted by the OS
Dismount-DiskImage -ImagePath 'C:\distros\Fedora\ext4.vhdx'
## make sure its not sparse
wsl --manage Fedora --set-sparse false
## run optimize
Optimize-VHD -mode full C:\distros\Fedora\ext4.vhdx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment