On Ubuntu 20.04 of WSL2, build the kernel source brought from kernel.org and use it as the kernel of WSL2.
stable: 5.9.6 2020-11-05
Install build tool
sudo apt update && \
sudo apt install -y build-essential flex bison libssl-dev libelf-dev pkg-config libncurses-dev
Download kernel source
cd ~
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.9.6.tar.xz
tar xvf linux-5.9.6.tar.xz
cd linux-5.9.6
Get .config
rm -rfv .config
wget https://raw.githubusercontent.com/microsoft/WSL2-Linux-Kernel/master/Microsoft/config-wsl -O .config
make menuconfig
Exit with <Exit>
=> <Yes>
Build
make -j 5 && sudo make modules_install`
Copy the kernel image (eg C: \ wslkernel \ kernel-5.9.6
)
mkdir -p /mnt/c/wslkernel
cp -v arch/x86/boot/bzImage /mnt/c/wslkernel/kernel-5.9.6
C:\Users\<username>\.wslconfig
[wsl2]
#memory=2GB
#processors=2
kernel=C:\\wslkernel\kernel-5.9.6
localhostForwarding=true
swap=0
Note that there are two backslashes (\\
) in the path specification.
Open PowerShell as an administrator and shut down the kernel.
wsl --shutdown
Restart Ubuntu
Recommended Posts