Skip to content

Commit b7a9a53

Browse files
committed
feat: Add instructions for compiling Linux kernel for WSL2
1 parent 06d9c18 commit b7a9a53

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

wsl/kernel.md

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Compile latest Linux kernel for WSL2
2+
3+
In order to use a [USB WiFi card](./usb.md), you need to compile them into the Linux kernel.
4+
5+
## Install build tools
6+
7+
```sh
8+
sudo apt update
9+
sudo apt install -y \
10+
build-essential flex bison \
11+
libgtk-3-dev libelf-dev libncurses-dev autoconf \
12+
libudev-dev libtool zip unzip v4l-utils libssl-dev \
13+
python3-pip cmake git iputils-ping net-tools dwarves \
14+
guvcview python-is-python3 bc
15+
```
16+
17+
## Clone the Linux kernel
18+
19+
```sh
20+
cd ~/src
21+
git clone https://github.com/microsoft/WSL2-Linux-Kernel.git wsl2-kernel
22+
```
23+
24+
## Configure the kernel
25+
26+
```sh
27+
cd ~/src/wsl2-kernel
28+
cp Microsoft/config-wsl .config
29+
make menuconfig
30+
```
31+
32+
Under `Device Drivers -> Network device support -> Wireless LAN`, enable the WiFi drivers you need and save the configuration.
33+
34+
## Build the kernel and install modules
35+
36+
```sh
37+
make -j$(nproc)
38+
sudo make modules_install headers_install
39+
cp arch/x86_64/boot/bzImage /mnt/d/wsl
40+
```
41+
42+
## Build the USBIP tools
43+
44+
```sh
45+
cd tools/usb/usbip
46+
./autogen.sh
47+
./configure
48+
make -j$(nproc)
49+
sudo make install
50+
```
51+
52+
## Install the custom kernel
53+
54+
Exit and shutdown WSL2 with `wsl --shutdown`. Then create/edit a file `.wslconfig` in your Windows user directory.
55+
56+
```ini
57+
[wsl2]
58+
kernel=d:\\wsl\\bzImage
59+
```
60+
61+
Start a new WSL session and check the kernel,
62+
63+
```sh
64+
$> uname -r
65+
6.6.36.3-microsoft-standard-WSL2+
66+
```
67+
68+
## Drivers
69+
70+
The following are as yet unsuccessful attempts to get WiFi drivers working.
71+
72+
```sh
73+
sudo apt update
74+
sudo apt install firmware-misc-nonfree
75+
```
76+
77+
```sh
78+
sudo modprobe vhci_hcd
79+
sudo modprobe mt76x2u
80+
lsmod
81+
```

wsl/usb.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Connect USB device to WSL
22

3+
For WiFI drivers, you may need to [Recompile the Linux Kernel](./kernel.md).
4+
35
Install `usbipd`,
46

57
```sh

0 commit comments

Comments
 (0)