Files
code-snippets/docs/wsl/clear-unused-disk-space.md
T
LiamPietralla bcb2a244ee
Build, Test & Publish / Build (push) Successful in 1m40s
Build, Test & Publish / Build and Publish Container Image (push) Successful in 3m6s
Build, Test & Publish / Deploy to Infrastructure (push) Successful in 39s
wsl items
2026-07-09 12:48:16 +10:00

526 B

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:

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