Inhaltsverzeichnis
< Alle Themen
Drucken

WSL2+ Kernel V6 Howto for Windows 11

# WSL2+ Kernel V6 Howto for Windows 11
Version 1 02/2024 by toxwood (mail@rbconnect.eu) https://rbconnect.eu/kb/wsl2-kernel-v6-howto-for-windows-11/
Instructions for building an x86_64 WSL2 kernel with an Ubuntu distribution (Howto uses Ubuntu 22.04.3 LTS) are
as follows:

# Ubuntu 22.04.3 LTS Requirements
Open a WSL terminal window and launch the distro of your choice.

Install the required packages to build the kernel:

`sudo apt update && sudo apt upgrade && sudo apt install bc dwarvesbc pahole build-essential flex bison libssl-dev libelf-dev`

Clone the Microsoft Linux kernel repository from GitHub:

`git clone https://github.com/microsoft/WSL2-Linux-Kernel.git –depth=1 -b linux-msft-wsl-6.1.y`

Change directory to the kernel source code:

`cd WSL2-Linux-Kernel`

# Build the Kernel:

`sudo make KCONFIG_CONFIG=Microsoft/config-wsl`

Install the kernel modules and headers:

`sudo make modules_install headers_install`

# Installing the Kernel:

Copy the kernel image to the Windows file system:

`sudo cp arch/x86/boot/bzImage /mnt/c/wslkernel`

Open Windows Explorer copy the kernel from the “c:\wslkernel” folder to the root of C:\
(Windows security confirmation required).

Exit the WSL terminal window.

# Using the Kernel

You can configure WSL to use it instead of the stock kernel as follows.
Create or edit the file `%USERPROFILE%\.wslconfig` with the following content:

`[wsl2]`

`Kernel=C:\\bzImage`

Open a PowerShell terminal window as Administrator and Stop the WSL instance:

`wsl –shutdown`

Now you can now launch your WSL2 distro and check the kernel version as follows:

Open a WSL terminal window and launch the distro of your choice.

Check the kernel version:

`uname -r`

You should see the following output:

` 6.1.21.2-microsoft-standard-WSL2+`

# Documentation

wsl2-kernel: https://github.com/microsoft/WSL2-Linux-Kernel

about-wsl2: https://docs.microsoft.com/en-us/windows/wsl/about#what-is-wsl-2

wsl-issue: https://github.com/microsoft/WSL/issues/new/choose

normal-bug: https://www.kernel.org/doc/html/latest/admin-guide/bug-hunting.html#reporting-the-bug

security-bug: https://www.kernel.org/doc/html/latest/admin-guide/security-bugs.html

submit-patch: https://www.kernel.org/doc/html/latest/process/submitting-patches.html

.wslconfig-inst: https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfig