Holochain Forum

Running low on diskspace while developing in WSL2

Just a heads up for anyone who is developing zomes, happs or fiddling around with the holochain repository.

WSL2 has the annoying habit of ever increasing in disksize. My Ubuntu was using 110Gb on windows, even though I had only about 27Gb worth of files in Ubuntu.

It’s a know issue, and there is a workaround.

First you have to find your virtual harddrive (.vhdx)

Users\<your username>\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx

CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc this will be different on your machine

Then run the following in powershell or cmd as administrator:

wsl --shutdown

This will open the diskpart command prompt, where you execute the following:

select vdisk file="<PATH-TO-VHDX>"
attach vdisk readonly
compact vdisk
detach vdisk

For a more detailed explanation and alternative methods you can go to:


First, remember to wsl --shutdown
Then, (I’d recommend) Optimize-VHD path-to-ext4.vhdx in an elevated powershell.

Much more succinct.

@The-A-Man thanks for noticing. I updated the instructions.

Optimize-VHD path-to-ext4.vhdx is definitely the easier way, but it only works on Windows Pro (not on Windows Home) and only if you have Hyper-V enabled.
I run WSL, but without Hyper-V tools enabled

TLDR; Try both: one of them should work

1 Like

Ohh, didn’t knew, since it has always worked for me (Win Pro with Hyper-V; dockerD back then required Hyper-V feature to be enabled first; had to very deeply scavenge an Azure VM that supported virtualization; but now even Docker has adopted WSL2; thought that was worth mentioning).

1 Like