PS2 [Tutorial] Windows WSL Performance Tweaks

e.v.o

Forum Noob
Since the Windows version 2004 feature update is available i encourage you all to update your dev pcs to that version.

In this post i am going to address the process in upgrading your WSL 1 distribution to WSL 2 and how to gain a performance boost using a custom .wslconfig (%USERPROFILE%\.wslconfig). Just copy/paste the commands listed below and you are good to go. This will also greatly improve your Docker performance.

If you have questions, comments or just want to rant about this post then feel free to do so.

  1. Enable the "Virtual Machine Platform" optional feature

    Open PowerShell as Administrator and run:
    Code:
    dism /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
  2. Restart your system
  3. Install Linux kernel update package

    Open PowerShell as Administrator and run:
    Code:
    Invoke-WebRequest -Uri 'https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi' -OutFile "$env:TEMP\wsl_update_x64.msi"
    Start-Process msiexec.exe -Wait -ArgumentList '/I %TEMP%\wsl_update_x64.msi /quiet'
    wsl --set-default-version 2

    What it does:
    Download the Linux kernel update package
    Install Linux kernel update package on your machine for use with WSL 2
    Set WSL 2 as your default version for new linux distributions
  4. Convert your existing distribution(s) to WSL 2

    Open PowerShell as Administrator and run:
    Code:
    wsl --shutdown
    wsl --list --verbose
    wsl --set-version NAME 2 # Replace NAME with one of the listed

    What it does:
    Shutdown all running wsl instances. Will shutdown every running WSL instance!
    List available WSL distributions
    Convert the given WSL 1 to WSL 2. This step might take some time.​

    Example from my machine:
    Code:
    PS C:\Users\Velocet> wsl --list --verbose --all
      NAME            STATE           VERSION
    * Ubuntu-18.04    Running         1
      Arch            Stopped         2
      Ubuntu-20.04    Stopped         1
    PS C:\Users\Velocet> wsl --shutdown
    PS C:\Users\Velocet> wsl --set-version Ubunto-18.04 2
    ...
    PS C:\Users\Velocet> wsl --list --verbose --all
      NAME            STATE           VERSION
    * Ubuntu-18.04    Stopped         2
      Arch            Stopped         2
      Ubuntu-20.04    Stopped         1
  5. Configure global WSL 2 options with .wslconfig
    Code:
    $wslconfig = '[wsl2]
    kernelCommandLine=noibrs noibpb nopti nospectre_v1 nospectre_v2 nospec_store_bypass_disable no_stf_barrier spectre_v2_user=noibrs noibpb nopti nospectre_v1 nospectre_v2 nospec_store_bypass_disable no_stf_barrier spectre_v2_user=off spec_store_bypass_disable=off l1tf=off mitigations=off mds=off tsx_async_abort=off  spectre_v2=off kvm.nx_huge_pages=off kvm-intel.vmentry_l1d_flush=never ssbd=force-off tsx=on'
    New-Item -Path "$env:USERPROFILE" -Name '.wslconfig' -ItemType File -Value $wslconfig

    What it does:
    Create a variable ($wslconfig) with additional kernel command line arguments.
    Create .wslconfig in your user profile folder and fill it with the $wslconfig variable. This file configures the global WSL (2) options.
    Kernel command line parameters explanation: kernel-parameters.txt
  6. Additional steps:
    • Disable Spectre/Meltdown mitigations on Windows
      If you haven't already disabled spectre/meltdown mitigations on Windows i greatly encourage you to do so using InSpectre. There is no sense in crippling the performance of your home computer.
    • Add your WSL distribution folder to the Windows Defender/Security exclusion list
      How to add an exclusion to Windows Security.
      Path to your WSL distribution: %LOCALAPPDATA%\Packages\
      Example for Ubuntu-20.04: %LOCALAPPDATA%\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc
 
We should merge the info from the tutorial I wrote back in the days and your tutorial here...!

Maybe we can create a PDF including all Infos! We could make that a little open documentation-project where others could contribute as well!

A document about WSL&Docker and performance-stuff and IDEs and so on...
 
This is kinda cool. I didn't know Microsoft were releasing a second version of WSL.
And it finally uses a dedicated Linux kernel. This is great.
Unfortunately I dropped Windows for Ubuntu on my home server but I'm still not quite prepared to give up a Windows environment on my main desktop PC, so I will install this new WSL 2 for Linux purposes on there instead.

Little off topic, where do you guys go to learn command line stuff? A simple Google search for my problem usually results in a fix, but I'd like to properly learn. My job is shit, my shoulder is injured... I need a new career
 
Actually WSL2 is lower, not faster. ;) But it is also better. And finally it using partition image instead files spread in NTFS space with additional more for keeping Linux file systems attribs.

To bad it doesn't support any external kernels.

@Fin9ersMcGee He did it with last major update (build 2004 if I remember correctly).

Both WSL1 and WSL2 using MS custom kernel with some flaws and limitations. ;)

In old days there was MS knowledge base but currently only spiders running on them. And if You want cancer instead of new job, start study PowerShell syntax. Everything else in compare is just piece of cake.
 
Last edited:
Actually WSL2 is lower, not faster. ;) But it is also better. And finally it using partition image instead files spread in NTFS space with additional more for keeping Linux file systems attribs.

To bad it doesn't support any external kernels.

@Fin9ersMcGee He did it with last major update (build 2004 if I remember correctly).

Both WSL1 and WSL2 using MS custom kernel with some flaws and limitations. ;)

In old days there was MS knowledge base but currently only spiders running on them. And if You want cancer instead of new job, start study PowerShell syntax. Everything else in compare is just piece of cake.

I checked today and I'm still on 1803, with nothing in Windows update except a "You need to update to the latest version" and no link to click.

I hate Windows. It's buggy and a resource hog. But like most people, I was brought up on it. And game compatibility is better (although I read some promising stuff about Ubuntu 20.04 and better GPU driver/direct x compatibility)
 
Update is not for everyone as some serious bugs was discovered. However, You can update it via disc or usb. And remember to change user-agent in web browser to Linux, iOS, MacOS or Android, otherwise You will not download *.iso but spyware to ISO assembling (very slow).
https://www.microsoft.com/en-us/software-download/windows10ISO

Games written for DX will always work better on Windows. Personally I don't playing games on PC, and even working on Windows 7. W10 is a literally disaster and I will never install it for my daily use. It looks ugly and works exactly as it looks.
 
I'm in the process of writing a complete tutorial on how to use Visual Studio Code under Windows and WSL(2) for PS2 development which also incorporates this tutorial.

Actually WSL2 is slower, not faster. ;) But it is also better. And finally it using partition image instead files spread in NTFS space with additional more for keeping Linux file systems attribs.
This depends on the task and is just not true but that they finally use VHDs is a very good thing.

To bad it doesn't support any external kernels.
You could build and run your own kernel without any problem. Just get the kernel config from Microsofts GitHub and then you could use something like the ClearLinux kernel with the mentioned Ubuntu (or any other distro .. i mostly use Arch).

Both WSL1 and WSL2 using MS custom kernel with some flaws and limitations. ;)
Since it's not a fully fledged VM thats the case but it's no harm in the case of PS2 development. And i did not encounter any serious flaws or limitations with WSL2. Which flaws and limitations do you mean?

And if You want cancer instead of new job, start study PowerShell syntax. Everything else in compare is just piece of cake.
Since i use MacOS, Windows and Linux i adore PowerShell and it's object based approach. And the syntax is way more consistent than on any *nix shell. You seem like a grumpy old guy that won't adopt new things. :D
If you like or don't like PowerShell its approach makes way more sense today then those *sh shells. But lets not discuss this topic here .. there is the right tool for every job out there and anyone is used to something else which gets the job done for him.

Unfortunately I dropped Windows for Ubuntu on my home server but I'm still not quite prepared to give up a Windows environment on my main desktop PC, so I will install this new WSL 2 for Linux purposes on there instead.
No need to use WSL2 since Visual Studio Code could connect to your Ubuntu via remote if you prefer that. This is just up to you.

Little off topic, where do you guys go to learn command line stuff? A simple Google search for my problem usually results in a fix, but I'd like to properly learn. My job is shit, my shoulder is injured... I need a new career
I use PowerShell on a daily basis in my job and i really like it (when working with Windows systems) as it gets the job done in a very pleasant way. Don't listen to Berion .. every PowerShell command works the same way .. and you get an object back instead of just raw data. If you want a good paid job with no fuckups: learn PowerShell ... it works with ActiveDiretory, InTune, MSSQL Server, SharePoint, Exchange, etc.

Update is not for everyone as some serious bugs was discovered. However, You can update it via disc or usb. And remember to change user-agent in web browser to Linux, iOS, MacOS or Android, otherwise You will not download *.iso but spyware to ISO assembling (very slow).
https://www.microsoft.com/en-us/software-download/windows10ISO
If you want to update you could use this tool: Windows 10 Update Assistent
And if you just want the iso there is this handy site: https://tb.rg-adguard.net/public.php

And really.. i just don't get the Windows hate. It's not more or less buggy than Linux or macOS. The Windows UI is a mess .. but you could install another WM if you want. You can change the taskbar, start menu, explorer .. no one is forcing you to use the standard Windows tools but most people complain without knowledge that there are tools out there that will get rid of most shitty stuff on Windows. Just like on every other OS ;)
 
  • Like
Reactions: TnA
I'm in the process of writing a complete tutorial on how to use Visual Studio Code under Windows and WSL(2) for PS2 development which also incorporates this tutorial.


This depends on the task and is just not true but that they finally use VHDs is a very good thing.


You could build and run your own kernel without any problem. Just get the kernel config from Microsofts GitHub and then you could use something like the ClearLinux kernel with the mentioned Ubuntu (or any other distro .. i mostly use Arch).


Since it's not a fully fledged VM thats the case but it's no harm in the case of PS2 development. And i did not encounter any serious flaws or limitations with WSL2. Which flaws and limitations do you mean?


Since i use MacOS, Windows and Linux i adore PowerShell and it's object based approach. And the syntax is way more consistent than on any *nix shell. You seem like a grumpy old guy that won't adopt new things. :D
If you like or don't like PowerShell its approach makes way more sense today then those *sh shells. But lets not discuss this topic here .. there is the right tool for every job out there and anyone is used to something else which gets the job done for him.


No need to use WSL2 since Visual Studio Code could connect to your Ubuntu via remote if you prefer that. This is just up to you.


I use PowerShell on a daily basis in my job and i really like it (when working with Windows systems) as it gets the job done in a very pleasant way. Don't listen to Berion .. every PowerShell command works the same way .. and you get an object back instead of just raw data. If you want a good paid job with no fuckups: learn PowerShell ... it works with ActiveDiretory, InTune, MSSQL Server, SharePoint, Exchange, etc.


If you want to update you could use this tool: Windows 10 Update Assistent
And if you just want the iso there is this handy site: https://tb.rg-adguard.net/public.php

And really.. i just don't get the Windows hate. It's not more or less buggy than Linux or macOS. The Windows UI is a mess .. but you could install another WM if you want. You can change the taskbar, start menu, explorer .. no one is forcing you to use the standard Windows tools but most people complain without knowledge that there are tools out there that will get rid of most shitty stuff on Windows. Just like on every other OS ;)

I've used the various debloating scripts for Win 10. They work pretty well.
My main gripe with Windows is mainly resource management. With Windows, my PC sits around 15% to 20% CPU usage, while a Linux flavour without a desktop GUI uses practically none at all.
 
You could build and run your own kernel without any problem.

But not any kernel. That's difference. I cannot take i.e Ubuntu kernel, compile on WSL2 (or take already compiled from my distro of use) and attach it to config. This must be the MS kernel or modified MS kernel.

Which flaws and limitations do you mean?

It have very stripped source code. In example, I cannot compile kernel modules and load them for this reason on WSL2 which using cut off code. I know that it is not full VM, it is just playtoy for dev-ops (Docker etc.) but well, would be.

every PowerShell command works the same way ..

Especially on older PS deployed in Windows 7, 8, and 8.1. :P

Since i use MacOS, Windows and Linux i adore PowerShell and it's object based approach. And the syntax is way more consistent than on any *nix shell. You seem like a grumpy old guy that won't adopt new things.

Syntax of PS is long as hell (in summary much shorter than bash, but I have in mind that commands to write are veeeeery long), hard to remember and tiresome to write. And again, as You mentioned, it is object oriented which I took as flaw not a feature. Definitely I'm this "old grumpy guy that won't adopt new things" which doesn't work everywhere and every time because as long as You will stick to binutils on Linux, You can run the same script across ALL Linux's which we cannot say the same on PS. For sure PowerShell is far way better than CMD which stopped evolving in around '95 but it is not king on white horse but cancer.

And really.. i just don't get the Windows hate.

I hate Windows 10, not Windows. That's difference. Mainly for atrocity GUI and moving QA to client side... This is unstable, unpredictable, annoying, spying piece of shit.
 
  • Like
Reactions: TnA
I've used the various debloating scripts for Win 10. They work pretty well.
My main gripe with Windows is mainly resource management. With Windows, my PC sits around 15% to 20% CPU usage, while a Linux flavour without a desktop GUI uses practically none at all.
Don't use those scripts cause most of these guys who put them togehter have no understanding of how Windows works and in which way to apply such settings. There is also a problem that a lot of these things change over time and most of the scripts use settings that just don't exist anymore or are renamed. Please use tools like O&O ShutUp, https://wpd.app or similar. The problem with those debloat scripts is that they work on the running system. Normally you mount the install.wim of a Windows iso file and remove the packages from there but that involves some work. I wrote a PS script that does mostly the same as NTlite does... maybe i put it on GH but the code is very rough. Do you really think that Microsoft would ship Windows with 15% - 20% idle? My system idles at max. 3%. Most of the time it's less. It all depends on what is running on your system and how you configured it.

Windows 10 LTSC 2019 is a stripped down version of Windows that has no modern apps or anything like it. It only gets security updates and not like any other Windows these so called "Feature Updates/Upgrades". Get this version if you don't need the newest features, modern apps, windows store, etc.

I use Windows 10 Enterprise v2004 as my main workstation and i am quite happy now. As i wrote in the tutorial: please disable Spectre/Meltdown mitigations wherever you find them.

But not any kernel. That's difference. I cannot take i.e Ubuntu kernel, compile on WSL2 (or take already compiled from my distro of use) and attach it to config. This must be the MS kernel or modified MS kernel.
You quoted me... but only one sentence. The sentence right after that explained it: use the config from Microsoft to build the kernel. Thats the same way every vendor does when they build Linux for their plattform (eg. a embedded device with some obscure hardware features). Latest WSL Kernel Configuration: https://github.com/microsoft/WSL2-Linux-Kernel/blob/master/Microsoft/config-wsl

It have very stripped source code. In example, I cannot compile kernel modules and load them for this reason on WSL2 which using cut off code. I know that it is not full VM, it is just playtoy for dev-ops (Docker etc.) but well, would be.
Yeah .. it's sad that it's monolithic but it gets the job done for most of us. I also have my ArchLinux VM cause i don't always trust the output or errors in WSL (especially when compiling...). But nothing to complain since WSL2... hope it stays that way ^^

Especially on older PS deployed in Windows 7, 8, and 8.1. :P

Syntax of PS is long as hell (in summary much shorter than bash, but I have in mind that commands to write are veeeeery long), hard to remember and tiresome to write. And again, as You mentioned, it is object oriented which I took as flaw not a feature. Definitely I'm this "old grumpy guy that won't adopt new things" which doesn't work everywhere and every time because as long as You will stick to binutils on Linux, You can run the same script across ALL Linux's which we cannot say the same on PS. For sure PowerShell is far way better than CMD which stopped evolving in around '95 but it is not king on white horse but cancer.
- long syntax: whats the point here? there are abbreviations for most stuff. also type one letter, hit tab and auto completion kicks in. This works out of the box and for every new module you install which is not the case with any *sh shell. You can use the long syntax or the short one. When working inside the shell you wont write "Invoke-Webrequest" but rather "iwr". And this syntax is compliant on every Windows version and every PowerShell version up to 5.1 (which is the standard on all systems by default) without any user configuration at all...
- object: i can't see any argument against it here? you want the raw data just convert the object. makes way more sense. i have way more information right on hand. funny thing is that i rarely use PS on Linux/macOS cause it just doesn't feel right and i love my zsh config. Does it make sense? Nope :D
- binutils example: i came across so many scripts that just won't work with fish or zsh. thats why they get sometimes called with "bash setup.sh". PS is not intended to run shell scripts from the normal *sh shells.

I hate Windows 10, not Windows. That's difference. Mainly for atrocity GUI and moving QA to client side... This is unstable, unpredictable, annoying, spying piece of shit.
The german government did a study and it's possible to get rid of those spying stuff when using LTSC 2019 or the Enterprise edition. But since every major browser or big software nowadays ships with a shitload of this bullshit it's just a fight we already lost (it seems..) :(
But yeah.. UI wise it sux big time ... and also that QA client side thing is just funny .. but i think it's better then before. If you just look at it .. then the Linux community does nothing else with their Daily builds and previews.

I love all of three major OSes. They all have their up- and downsides :)
 
Last edited:
  • Like
Reactions: TnA
Don't use those scripts cause most of these guys who put them togehter have no understanding of how Windows works and in which way to apply such settings. There is also a problem that a lot of these things change over time and most of the scripts use settings that just don't exist anymore or are renamed. Please use tools like O&O ShutUp, https://wpd.app or similar. The problem with those debloat scripts is that they work on the running system. Normally you mount the install.wim of a Windows iso file and remove the packages from there but that involves some work. I wrote a PS script that does mostly the same as NTlite does... maybe i put it on GH but the code is very rough. Do you really think that Microsoft would ship Windows with 15% - 20% idle? My system idles at max. 3%. Most of the time it's less. It all depends on what is running on your system and how you configured it.

Windows 10 LTSC 2019 is a stripped down version of Windows that has no modern apps or anything like it. It only gets security updates and not like any other Windows these so called "Feature Updates/Upgrades". Get this version if you don't need the newest features, modern apps, windows store, etc.

I use Windows 10 Enterprise v2004 as my main workstation and i am quite happy now. As i wrote in the tutorial: please disable Spectre/Meltdown mitigations wherever you find them.

I've looked into Enterprise and LTSC, used it a couple of times but mainly on old or underpowered hardware. But I could never afford an Enterprise license nor do I know someone who works in the IT department of a company or school to give me one for free.

The debloating scripts I use are mainly to disable cortana, remove pre installed store apps and just general tidy up of the start menu etc. It claims to remove telemetry, but I doubt that. And I've also read somewhere that the changes most scripts accomplish are reverted when Windows updates anyway.

My PC is mainly for games these days. Or as an access terminal to the VMs on my server. But that's pretty rare as I have a nifty little 7 inch laptop that does the same thing but with a crap ton less power consumption
 
I would never say you should totally pirate a license for a product you normally could never buy from a billion dollar company that won't hurt them anyway. But if you would do it, i wouldn't condemn you. Drop me a PM if you need assistance...

Yeah.. thats also a problem with those scripts: When you install an update it gets reverted. I also disable SmartScreen and Defender. They really suck a lot of ressources...
 
I would never say you should totally pirate a license for a product you normally could never buy from a billion dollar company that won't hurt them anyway. But if you would do it, i wouldn't condemn you. Drop me a PM if you need assistance...

Yeah.. thats also a problem with those scripts: When you install an update it gets reverted. I also disable SmartScreen and Defender. They really suck a lot of ressources...

Just a friendly reminder about piracy, we don't discuss such things here.
But I'll give you the benefit of the doubt as this is a minor discussion and not a full blown "This is how and where you pirate windows" situation.
Just remember for next time.

In an ideal world, I'd have a job that provides such a license. But until then, I'll happily chug along on Win 10 Pro or Unix flavours.
If only I could purchase a "second hand" Enterprise license like I can with Windows 10 Pro at £1.50 per license... That'd be sweet. But alas, it still costs hundreds for Enterprise off ebay.
 
I have the feeling, that we got new people into the scene and others learned many things during the past year!

Awesome!

This scene will prosper, IMO! :D
 
I have the feeling, that we got new people into the scene and others learned many things during the past year!

Awesome!

This scene will prosper, IMO! :D

Surprisingly, the scene isn't why I got into Linux.
My first experience was around 2005 using old enterprise thin clients as Web servers. All very basic things though as I was totally new to command line stuff, let alone Linux.
My most recent venture was setting up a home server running Proxmox and various Linux VMs, purely to get myself on a path to a new career, I've always been a practical learner so just jumping straight into hardware/software was always a great idea for me.

I've not even setup netserver for ps3 or SMB shares for Ps2, lol.
 

Similar threads

Back
Top