Skip to content

Instantly share code, notes, and snippets.

@cmpute
Created August 13, 2022 07:20
Show Gist options
  • Save cmpute/e8a3ee05ddeda157175663d168f2310c to your computer and use it in GitHub Desktop.
Save cmpute/e8a3ee05ddeda157175663d168f2310c to your computer and use it in GitHub Desktop.
Shrink WSL2 virtual hard drive
wsl --shutdown
diskpart :: opening a separate window
select vdisk file="C:\Users\{user}\AppData\Local\Packages\…\ext4.vhdx"
attach vdisk readonly :: this step is necessary to prevent process conflict
compact vdisk
detach vdisk
exit
@cmpute
Copy link
Author

cmpute commented Mar 1, 2023

Just for example, the hard drive file in my laptop is located at:

C:\Users\cmput\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment