Skip to content

Latest commit

 

History

History
81 lines (60 loc) · 1.53 KB

kernel.md

File metadata and controls

81 lines (60 loc) · 1.53 KB

Compile latest Linux kernel for WSL2

In order to use a USB WiFi card, you need to compile them into the Linux kernel.

Install build tools

sudo apt update
sudo apt install -y \
    build-essential flex bison \
    libgtk-3-dev libelf-dev libncurses-dev autoconf \
    libudev-dev libtool zip unzip v4l-utils libssl-dev \
    python3-pip cmake git iputils-ping net-tools dwarves \
    guvcview python-is-python3 bc

Clone the Linux kernel

cd ~/src
git clone https://github.com/microsoft/WSL2-Linux-Kernel.git wsl2-kernel

Configure the kernel

cd ~/src/wsl2-kernel
cp Microsoft/config-wsl .config
make menuconfig

Under Device Drivers -> Network device support -> Wireless LAN, enable the WiFi drivers you need and save the configuration.

Build the kernel and install modules

make -j$(nproc)
sudo make modules_install headers_install
cp arch/x86_64/boot/bzImage /mnt/d/wsl

Build the USBIP tools

cd tools/usb/usbip
./autogen.sh
./configure
make -j$(nproc)
sudo make install

Install the custom kernel

Exit and shutdown WSL2 with wsl --shutdown. Then create/edit a file .wslconfig in your Windows user directory.

[wsl2]
kernel=d:\\wsl\\bzImage

Start a new WSL session and check the kernel,

$> uname -r
6.6.36.3-microsoft-standard-WSL2+

Drivers

The following are as yet unsuccessful attempts to get WiFi drivers working.

sudo apt update
sudo apt install firmware-misc-nonfree
sudo modprobe vhci_hcd
sudo modprobe mt76x2u
lsmod