A patch to compile Linux Kernel for WSL2. This patch includes a default config file for WSL2 and a script to compile the kernel.
- Download the kernel source code from kernel.org.
- Extract the source code.
- Copy the patch file to the source code directory.
- Run
patch -p1 < wsl2_kernel.patch
to apply the patch. - Run
yes "" | make oldconfig
to use the default config file. - Run
make -j$(nproc)
to compile the kernel.
Run sudo make modules_install
to install the modules.
To use the kernel in WSL2, you need to copy the kernel image bzImage located in arch/x86/boot/
to a directory in your Windows user profile. If you don't have a .wslconfig file in your Windows user profile, create one. Add the following lines to the file:
[wsl2]
kernel=C:\\Users\\<username>\\bzImage