Compile Mainline Kernel for WSL2
Steps for compile Kernel Linux 5.11.0 💕 Valentine's Day Edition 💕
$ uname -a
Linux DESKTOP-ID 4.19.128-microsoft-standard # 1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 GNU/Linux
$ mkdir -p linux
$ cd linux
Install Requirements for Build
$ sudo apt install git bc build-essential flex bison libssl-dev libelf-dev
Download Linux source code
$ wget https://github.com/torvalds/linux/archive/v5.11.zip -O v5.11.zip
Prepare the directory as Case Sensitive.
> $linuxSrc = " linux-5.11"
> $net_netfilter = " $linuxSrc \net\netfilter"
> $uapi_netfilter = " $linuxSrc \include\uapi\linux\netfilter"
> $uapi_netfilter_ipv4 = " $linuxSrc \include\uapi\linux\netfilter_ipv4"
> $uapi_netfilter_ipv6 = " $linuxSrc \include\uapi\linux\netfilter_ipv6"
> $subfolders = @ (" $linuxSrc " , " $linuxSrc \net" , " $net_netfilter " , " $linuxSrc \include" , " $linuxSrc \include\uapi" , " $linuxSrc \include\uapi\linux" , " $uapi_netfilter " , " $uapi_netfilter_ipv4 " , " $uapi_netfilter_ipv6 " )
> # Create sub-folders
> $subfolders | % {New-Item - Path " .\$_ " - ItemType Dir}
Set Case Sensitive. Run as Administrator!
> @ ($net_netfilter , $uapi_netfilter , $uapi_netfilter_ipv4 , $uapi_netfilter_ipv6 ) | % {fsutil.exe file setCaseSensitiveInfo " $_ " enable}
Check Case Sensitive. Run as Administrator! (Optional)
> fsutil.exe file queryCaseSensitiveInfo $net_netfilter
El atributo que distingue mayúsculas de minúsculas del directorio .\linux- 5.11 \net\netfilter está habilitado.
$ wget https://raw.githubusercontent.com/microsoft/WSL2-Linux-Kernel/linux-msft-wsl-4.19.y/Microsoft/config-wsl
Copy Config WSL as Default Config to the Linux configs
$ cp config-wsl linux-5.11/arch/x86/configs/wsl_defconfig
Generate the Configuration and Build
$ cd linux-5.11
$ make KCONFIG_CONFIG=arch/x86/configs/wsl_defconfig -j2
Copy Linux kernel to YOUR_USER
$ cp vmlinux /mnt/c/Users/YOUR_USER/
Edit the configuration for WSL
$ vim /mnt/c/Users/YOUR_USER/.wslconfig
[wsl2]
kernel=C:\\Users\\YOUR_USER\\vmlinux
Check shutdown the distro WSL
$ uname -a
Linux DESKTOP-ID 5.11.0-oleksis # 1 SMP Fri Feb 26 19:48:22 CST 2021 x86_64 GNU/Linux
Extras
Mount externals disk drivers. Run as Administrator!
wmic diskdrive list brief
wsl -- mount \\.\PHYSICALDRIVE1 -- bare
Hi @homeassistant-hacs-m for more advanced commands check: wslinternals - A collection of some nifty WSL-related utilities