Skip to content

Instantly share code, notes, and snippets.

@willyneutron
Created September 7, 2020 18:05
Show Gist options
  • Save willyneutron/0660f013af351cdf4540728e3848d8a9 to your computer and use it in GitHub Desktop.
Save willyneutron/0660f013af351cdf4540728e3848d8a9 to your computer and use it in GitHub Desktop.
Compile WSL2 kernel to compile modules
Getting the kernel code
-----------------------
Download the kernel you want from here:
https://github.com/microsoft/WSL2-Linux-Kernel/tags
```
cd /tmp
wget "https://github.com/microsoft/WSL2-Linux-Kernel/archive/4.19.104-microsoft-standard.tar.gz"
tar -xzvf 4.19.104-microsoft-standard.tar.gz
```
Compile and install
-------------------
Install compilation dependencies:
```
sudo apt install git bc build-essential flex bison libssl-dev libelf-dev
```
Compile the kernel:
```
make KCONFIG_CONFIG=Microsoft/config-wsl -j $(nproc)
```
Install modules to be able to compile kernel modules:
```
sudo make -j $(nproc) modules_install
```
Sources
-------
https://microhobby.com.br/blog/2019/09/21/compiling-your-own-linux-kernel-for-windows-wsl2/
https://medium.com/@centerorbit/installing-wireguard-in-wsl-2-dd676520cb21
https://github.com/microsoft/WSL2-Linux-Kernel/issues/78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment