Created
          September 7, 2020 18:05 
        
      - 
      
- 
        Save willyneutron/0660f013af351cdf4540728e3848d8a9 to your computer and use it in GitHub Desktop. 
    Compile WSL2 kernel to compile modules
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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