Skip to content

Clear Unused Disk Space

WSL will grow but never shrink the size of the virtual disk. This can be a problem if you have a lot of unused space in your WSL virtual disk. You can reclaim this space by running the following command in PowerShell admin:

powershell
wsl --shutdown

# Navigate to the location of the ext4.vhdx file. This is usually in C:\Users\<username>\AppData\Local\Packages\<distro>\LocalState\ext4.vhdx

# Run the following command to compact the virtual disk
Optimize-VHD -Path .\ext4.vhdx -Mode Full