WSL: WSL 2 freezing with 100% disk usage after windows store update

Version

Windows 10.0.19044.2364 WSL version: 1.0.3.0

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.15.79.1

Distro Version

Ubuntu 20.04

Other Software

Docker Desktop Version 4.10.1 VSCode: 1.74.1 Remote WSL 0.72.0

Repro Steps

I am running our environment on WSL ( 3 docker containers plus react) whenever I work on the frontend, react compiles but after a while the disk usage shoots up to 100% (~750MB/s) in task manager and WSL freezes, I tried shutting down vscode assuming its causing the io but the io still remains high until force terminate the wsl instance using wsl --shutdown. This only started happening when Windows updated and I received a prompt to update to the windows store version. I did the update and enabled system md service (these are the only relevant things I can think of which will cause this issue).

Expected Behavior

The distro should run fine without any issues

Actual Behavior

100% disk usage leading to freezeup

Diagnostic Logs

tried running powershell log script but it errors out saying ampersand should be between double quotes. not sure If i should edit it and run it again

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 32
  • Comments: 35

Most upvoted comments

I did notice that the RAM consumption within my WSL was very high (PHP Intelephense from the VSCode server consumed a lot for example). So with my previous .wslconfig of only 5GB of memory and a default swap size of 2GB it started swapping pretty quickly - and then ran out of swap space, which likely causes this issue.

Currently I am using

[wsl2]
memory=10GB
processors=6
swap=4GB
kernelCommandLine="sysctl.vm.swappiness=10"

and this issue hasn’t occurred since.

I did not actually know that by removing the .wslconfig the WSL just consumes as much memory as it needs though.

Due to this issue, I stopped using WSL and now use native Linux instead.

This is a joke, completely unusable, time to buy a mac

@nelsonwellswku See WSL documentation here for WSL config information

In my case I’m using the global .wslconfig file at your Windows user profile directory. You need to create the file yourself if you haven’t previously used custom options (again, see the documentation for details).

For reference my whole config looks like this:

[wsl2]
swap=26GB
kernelCommandLine="sysctl.vm.swappiness=10"

[experimental]
autoMemoryReclaim=gradual

After editing the config you need to restart WSL (or the whole OS just to be sure) for the changes to take effect.

I had this issue and resolved it by clearing space on my SSD.

I had only 50GB of space left. When I cleared up another 60GB, to a total of 110GB of space left - the issue was gone.

I have 64GB RAM on my machine - this was never a RAM issue, nor does the SWAP usage got anywhere need 50GB, not even 10GB. Yet this is what fixed it for me.

Thanks, I still ended up with the newest WSL version a couple of times even after system reboot. What I’ve done in addition: uninstall Docker Desktop (to get rid of all distros including the 2 docker distros. You may also backup your images etc. before that). Also, I’ve downloaded & installed the “cab” file from the Microsoft catalog manually “Windows Subsystem for Linux Update - 5.10.16”. I know this version was installed before wsl --update on my machine (Win 10, 21H2, 19044.2364). That way I’ve ended up with the “older WSL2 version” that for some reason prints the help page on wsl --version instead of a version. I don’t know if both steps were needed really. btw the cab file 5.10.102.2 works for me without noticeable side effects, too.

You can downgrade even easier: Go to https://www.catalog.update.microsoft.com/Search.aspx?q=windows subsystem linux and download “Windows Subsystem for Linux Update - 5.10.102.2”. Uninstall the current WSL2 (using Settings -> Apps), then install the update.

i think the problem is the swap size on wsl2 is too small so i make some changes to my .wslconfig file

[wsl2]
memory=2300MB
swap=2GB
processors=4
kernelCommandLine = "sysctl.vm.swappiness=10"
  1. didn’t change memory
  2. increase swap from 1GB to 2GB ( i didn’t manully configure it to be 1GB before, according to microsoft this should be 25% of your windows memory size, so i thought it would be helpful to increase the swap size)
  3. increase processors from 2 to 4
  4. add the kernelCommandLine according to this post because i found it use 100% of swap even when it still got some memory budget which may have something to do with 100% disk usage?

i did some test by compiling some code and using services hosted by docker-desktop simultaneously which will trigger 100% disk usage problem before and it didn’t do that this time

will update if i ran into problem with this config

Increasing swap size is only solution that has 100% worked for me. Even if the swap never seems to be used it somehow needs to still be available…

How much swap you need depends on the project and how heavily file system operations are done.

Last year when I was struggling with this I ended up just increasing swap every time it happened. Every increase made it happen less often until eventually I never had the issue. My current config seems to be 26GB of swap and I haven’t seen the issue since last year:

swap=26GB kernelCommandLine=“sysctl.vm.swappiness=10”

But as said, what value you need may depend on various things so you may have to go even higher.

I doubt storage space makes much difference here. I had this issue happen even though my OS SDD typically has about 1TB free storage.

Only thing that helped was setting sysctl.vm.swappiness=10 and swap to same or higher than memory limit (>10GB).

I am experiencing the same issue. For me it typically happens when I run a yarn build task for a web project within Ubuntu. CPU and SSD usage will be at 100% where the SSD is continuously reading at 2 GiB/sec (while only writing at a speed of ~400 KiB/sec). My current .wslconfig only contains

[wsl2]
memory=5GB
processors=6

(this is on a 5900X with 12 cores / 24 threads and 32 GiB RAM). I’ll try @stanly0726 's suggestion and observe if that makes any difference.

@tonkolviktor do you mind sharing you .wslconfig ?

sure, see it above in th screenshot

thanks @stanly0726 @fritzmg

my config is

[wsl2] memory=1GB swap=512MB localhostForwarding=true kernelCommandLine=“sysctl.vm.swappiness=10”

adding swap and kernelCommandLine solve my 1GB/s disk usage

@fritzmg there are some limits as defaults for WSL2 - if you don’t specify any wslconfig file - you can check the “defaults” column in microsoft documentation : https://learn.microsoft.com/en-us/windows/wsl/wsl-config#configuration-setting-for-wslconfig - 50% allocated by default (I do have 32 GiB rams too, so it could take up to 16 GiB of memory). Aslo, for swap, it uses a default 25% of the memory - so is 8gb on a 32 GiB rig. Glad that you manage to tune the values so you don’t experience the issue any more.

I have the same issue multiple times a day, so it’s very annoying. wsl --shutdown; wsl and killing+starting Docker Desktop is my only solution to solve it so far. Do I loose all data (especially the home folder) when downgrading? Can somebody confirm that reinstalling WSL2 works?

I, too, suffer from this problem. I have found out how to downgrade WSL but this can only be a temporary fix.

First, uninstall WSL completely, for example as described in this tutorial. Then, reinstall WSL according to the manual instructions provided by Microsoft. I skipped step 2, 4 and 6. Finally, I reinstalled (in my case) Ubuntu via PowerShell (as admin) wsl --install --distribution Ubuntu-20.04 to avoid installing it via the Microsoft Store.

If you want to avoid running into the problem all over again (if you know that your machine is affected by this problem), do not run wsl --update for now and do not install WSL via the Microsoft Store.

Thanks, I still ended up with the newest WSL version a couple of times even after system reboot. What I’ve done in addition: uninstall Docker Desktop (to get rid of all distros including the 2 docker distros. You may also backup your images etc. before that). Also, I’ve downloaded & installed the “cab” file from the Microsoft catalog manually “Windows Subsystem for Linux Update - 5.10.16”. I know this version was installed before wsl --update on my machine (Win 10, 21H2, 19044.2364). That way I’ve ended up with the “older WSL2 version” that for some reason prints the help page on wsl --version instead of a version. I don’t know if both steps were needed really. btw the cab file 5.10.102.2 works for me without noticeable side effects, too.

I, too, suffer from this problem. I have found out how to downgrade WSL but this can only be a temporary fix.

First, uninstall WSL completely, for example as described in this tutorial. Then, reinstall WSL according to the manual instructions provided by Microsoft. I skipped step 2, 4 and 6. Finally, I reinstalled (in my case) Ubuntu via PowerShell (as admin) wsl --install --distribution Ubuntu-20.04 to avoid installing it via the Microsoft Store.

If you want to avoid running into the problem all over again (if you know that your machine is affected by this problem), do not run wsl --update for now and do not install WSL via the Microsoft Store.

thanks @stanly0726, unfortunatelly for me it did not fix it. I actually have this problem right after wsl start, I do not have to do anything to trigger it. What I notice additionally is that while this is 100% usage is happening the active window is “blinking”. It’s losing the focus and then gets it right back, and the cursor shows this loading circle…

PS> wsl.exe --version
WSL-Version: 1.0.3.0
Kernelversion: 5.15.79.1
WSLg-Version: 1.0.47
MSRDC-Version: 1.2.3575
Direct3D-Version: 1.606.4
DXCore-Version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows Version: 10.0.19042.2364

wsl wsl_2

how are you downgrading? there’s no official doc for downgrading WSL2 versions

well, it was just an idea, i’ve tried to install the .msixbundle however my windows version incompatibility did not allow me to do that.

Additionally it was pointed out to me that wsl might update itself on the --install so it might have been even pointless.

However an official option to install any version would be nice, since apparently wsl can be completely broken from one day to the next.

hello all, is there an update on this? or is there a workaround?

this makes wsl completly unusable.

I’m trying to downgrade, but the .msixbundle has too high min windows version:

Windows.Desktop mindestens die Betriebssystemversion 10.0.22000.0. Auf dem Gerät wird momentan die Betriebssystemversion 10.0.19042.2364 ausgeführt.

how are you downgrading? there’s no official doc for downgrading WSL2 versions