leandrw's blog

Speedup WSL by disabling Windows Real-time protection

In this short tutorial, I will help you speedup Windows Subsystem for Linux (WSL) by disabling Windows Real-time protection.

While being helpful detecting some common Windows malwares, in GNU/Linux side it’s so inefficient and actually unhelpful.

Every time you try to access/read/write some file/folder, Windows Defender intercept WSL requisition for antivirus scanning, slowing down things until you hate everything in WSL!

Screenshot of Windows Subsystem for Linux executing apt-get update downloading slow at 46.6 kB/s
Ubuntu running inside WSL trying to update some packages behind Windows Real-time protection bad guy

Warning: disabling Real-time Security may have some direct impact in yours personal security. Know what you are doing.

Adding WSL in the Windows Security's Exclusion List

So, first get the UbuntuOnLinux (or your distro of choice) installation path going to %USERPROFILE%\AppData\Local\Packages and lookup for something like CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc.

Copy the entire path from Explorer.exe address bar, then go to:

Settings > Update & Security > Windows Defender > Open Windows Defender Secutiry Central > Protection Against Viruses & Threats > Advanced Config… > Exclusions > Add or Remove > Add > Folder and finally: paste the previous copied path.

High security sometimes means Low performance

Screenshot of Windows Defender Security Center showing Real-time protection as disabled
Windows Defender Real-time slow down… protection

Adding WSL to exclusion list may speedup things a little bit, but not so. There is one more thing bringing your performance down: Window Defender real-time protection.

As noticed by David Tansey in this WSL issue, real-time protection have a HUGE impact in developer tools like Visual Studio build tool and tools like Kubernetes and etc., including WSL.

We will disable it, but be aware: you will may be more vulnerable for some common attacks through malicious script execution.

So, let’s disable:

Using Group Policy (gpedit.exe) to disable real-time protection:

Screenshot of Group Policy Editor (a.k.a. gpedit.msc)
Using Group Policy (gpedit.msc) to disable real-time protection
  1. On your Group Policy management machine, open the Group Policy Management Console, right-click the Group Policy Object you want to configure and click Edit.
  2. In the Group Policy Management Editor go to Computer configuration.
  3. Click Policies then Administrative templates.
  4. Expand the tree to Windows components > Windows Defender Antivirus > Real-time protection.
  5. Double-click the Turn off real-time protection setting and set the option to Enabled. Click OK.
I’ve only tested superficially, but I can ensure a great performance speed up.
Disclaimer: I have plans to improve my English skill, but my willing to help is bigger than that.


Configure always-on real-time protection in Windows Defender AV | Microsoft Docs — https://docs.microsoft.com/en-us/windows/threat-protection/windows-defender-antivirus/configure-real-time-protection-windows-defender-antivirus

First posted on Medium Speeding up WSL I/O up than 5x fast + saving a lot of battery life & CPU usage, as a reply to Epic Development Environment using Windows Subsystem for Linux

← Início