How to reduce wsl disk

As you use WSL, the VHDX disk image will grow. You need to compact it! 1. Cleanup Start by cleaning up the disk. Each user can choose their preferred method. 2. fstrim Once everything is clean, you can force the system to discard unused elements from the image. sudo fstrim -av 3. Installing wslcompact The wslcompact project is a PowerShell module that allows you to compact the disk efficiently. Set-ExecutionPolicy RemoteSigned -Scope CurrentUser iwr -useb https://raw.githubusercontent.com/okibcn/wslcompact/main/setup | iex Note: On the latest versions of WSL (2.5.4.0?), you may need to patch the file as shown in this commit. ...

April 2, 2025 · Last Modified: April 4, 2025 · 1 min