WSL 2 not only loads a native Linux Kernel, the image of the Linux Kernel is in the directory C:\Windows\System32\lxss\tools, but it also gives us the option of loading a customized Linux kernel. That’s right, we can compile and customize our own kernel to be loaded into WSL 2.
time make KCONFIG_CONFIG=arch/x86/configs/config-wsl -j8 modules time make KCONFIG_CONFIG=arch/x86/configs/config-wsl -j8 modules_install time make KCONFIG_CONFIG=arch/x86/configs/config-wsl -j8 tarxz-pkg
[wsl2] # An absolute Windows path to a custom Linux kernel # kernel=C:\\Users\\<seuUser>\\vmlinuz-6.6.36.3-WSL2 # kernel=C:\\Users\\<seuUser>\\vmlinuz-6.9.10-WSL2 # 50% of total memory on Windows or 8GB, whichever is less # memory=8GB # Sets additional kernel parameters, in this case enabling older Linux base images such as Centos 6 # kernelCommandLine = vsyscall=emulate systemd.unified_cgroup_hierarchy=1 cgroup_no_v1=all # kernelCommandLine = vsyscall=emulate systemd.unified_cgroup_hierarchy=1 cgroup_no_v1=named
Restart WSL2
1 2 3 4 5
wsl --version wsl --list --verbose wsl --shutdown
# taskkill /F /T /IM wslservice.exe
1
wsl
Check WSL2
WSL2 Linux Kernel
1 2
# cat /proc/version Linux version 6.6.36.3-microsoft-standard-WSL2+ (root@debian-stable) (gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT_DYNAMIC Fri Jul 19 07:04:59 UTC 2024
Stable Linux Kernel
1 2
# cat /proc/version Linux version 6.9.10-microsoft-standard-WSL2 (root@debian-stable) (gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT_DYNAMIC Fri Jul 19 02:25:29 UTC 2024