3 Gotchas with WSL 2 around Disk Space, Memory Usage and Performance
In this video, we'll identify and go over how to fix 3 different WSL 2 issues that'll likely cause you trouble over time.
As of July 2020, it’s easy to get in a situation where WSL 2 will eat up all of your disk space, use 80% of your memory and get poor file I/O performance when accessing mounted drives.
We’ll go over how to address all of these issues below. Everything we’ll go over will work for all editions of Windows 10.
Update: I also recorded a 2nd video that focuses on reclaiming a ton of disk space from Docker Desktop’s WSL 2 VM. I recommend watching that video after this one.
# Going Over Everything
Timestamps
- 0:30 – Combating poor file performance in WSL 2 when accessing mounted drives
- 2:38 – Ensuring WSL 2 doesn’t use up to 80% of your system’s memory
- 6:17 – Clearing out WSL 2’s memory usage on demand with a Bash alias
- 8:21 – Reclaiming disk space that WSL 2’s VM won’t free up by default
- 10:12 – Be careful because WSL 2 won’t auto-mount your external drives
- 12:56 – How to shrink your WSL 2 VM to reclaim disk space in PowerShell
- 18:10 – An alternative to the Optimize-VHD command on Windows 10 Home
- 19:10 – Recap and hopefully Microsoft fixes these issues in future WSL 2 patches
Reference Links
- https://github.com/microsoft/WSL/issues/4166
- https://github.com/microsoft/WSL/issues/4699
- https://github.com/nickjj/dotfiles
- Direct link to the drop cache alias
- https://github.com/microsoft/WSL/issues/4699#issuecomment-635673427
- https://github.com/microsoft/WSL/issues/4699#issuecomment-627133168
- https://nickjanetakis.com/blog/a-linux-dev-environment-on-windows-with-wsl-2-docker-desktop-and-more
Are you aware of any other gotchas with WSL 2? Let me know below.