|
| 1 | +# What is this fork about? |
| 2 | +This is the WSL2-Linux-Kernel that has been modified to enable loadable modules support and be able to use wireless adapters |
| 3 | + |
| 4 | +# How to get this kernel |
| 5 | + |
| 6 | +Make a directory named src |
| 7 | +`mkdir ~/src` |
| 8 | + |
| 9 | +Clone the kernel |
| 10 | +`git clone https://github.com/EDLLT/WSL2-Linux-Kernel.git` |
| 11 | + |
| 12 | +# How do I add a wireless adapter driver and enable it? |
| 13 | + |
| 14 | +Put your driver inside |
| 15 | +`drivers/net/wireless/realtek` |
| 16 | + |
| 17 | +2. Edit the Kconfig file inside ``drivers/net/wireless/realtek/Kconfig`` and make it point to your driver just like this commit below |
| 18 | +https://github.com/EDLLT/WSL2-Linux-Kernel/commit/e23de6383dcc5af1c2a50115029a9d318a63a997 |
| 19 | + |
| 20 | +3. Also edit the Makefile in ``drivers/net/wireless/realtek/Makefile`` and add the obj pointing to your driver just like below |
| 21 | +https://github.com/EDLLT/WSL2-Linux-Kernel/commit/2b0edd829739af7b6f601a54ba815c67b1d564ef |
| 22 | + |
| 23 | +4. Get into menuconfig |
| 24 | +`make -j $(expr $(nproc) - 1) KCONFIG_CONFIG=Microsoft/config-wsl menuconfig` |
| 25 | + |
| 26 | +5. Inside menuconfig goto |
| 27 | + `Device Drivers` (Hit Arrow down 15 times) |
| 28 | + `Network device support` (Hit arrow down 23 times) |
| 29 | + `Wireless LAN` (Hit arrow down 45 times) |
| 30 | + |
| 31 | +6. Now that you are in Wirelass LAN go down up until you find `Realtek devices`(~55 downs) |
| 32 | +& Find the driver you want to enable, in my case the driver I want to enable is called Realtek 8822B USB WiFi |
| 33 | +Press `M` to enable it, (MAKE SURE IT SAYS `M` NOT `*` FOR THE DRIVER YOU WANT OTHERWISE IT MIGHT ERROR) |
| 34 | + |
| 35 | +7. Save the configuration file as `Microsoft/config-wsl` |
| 36 | + |
| 37 | +Now once you've done everything proceed to the below `New Build Instructions` |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +# New Build Instructions |
| 43 | +1. Install the build dependencies: |
| 44 | + `sudo apt install build-essential flex bison dwarves libssl-dev libelf-dev` |
| 45 | + |
| 46 | +2. Load modules |
| 47 | + `make -j $(expr $(nproc) - 1) KCONFIG_CONFIG=Microsoft/config-wsl modules` |
| 48 | + |
| 49 | +3. modules_install |
| 50 | + `make -j $(expr $(nproc) - 1) KCONFIG_CONFIG=Microsoft/config-wsl modules_install` |
| 51 | + |
| 52 | +4. Build the kernel |
| 53 | + `make -j $(expr $(nproc) - 1) KCONFIG_CONFIG=Microsoft/config-wsl` |
| 54 | + |
| 55 | +Assuming that there were no errors you're safe to proceed |
| 56 | + |
| 57 | +5. A file called bzImage file will be created in `~/src/WSL2-Linux-Kernel/arch/x86/boot` copy the bzImage to /mnt/Users/YOUR_USER |
| 58 | + Note: Replace `YOURUSER` with your actual user |
| 59 | + |
| 60 | + `cp ~/src/WSL2-Linux-Kernel/arch/x86/boot/bzImage /mnt/c/Users/YOURUSER` |
| 61 | + |
| 62 | +6. Create a file called .wslconfig inside `/mnt/c/Users/YOURUSER` and edit it |
| 63 | + nano /mnt/c/Users/YOURUSER/.wslconfig |
| 64 | + |
| 65 | +7. Paste this in(Don't forget to replace YOURUSER with your actual user) then CTRL+X to save the file and hit enter |
| 66 | + ``` |
| 67 | + [wsl2] |
| 68 | + kernel=C:\\Users\\Hamid\\bzImageMODULESLOADED |
| 69 | + ``` |
| 70 | +8. goto windows command prompt and shutdown wsl(then wait for 10 seconds) |
| 71 | + `wsl --shutdown` |
| 72 | + |
| 73 | +Now try typing wsl, give it a second or two and it should work, (If it doesn't and you want to revert then delete the .wslconfig inside C:\Users\YOURUSER) |
| 74 | + |
| 75 | +# How to load the module for the driver |
| 76 | + |
| 77 | +Goto your kernel directory |
| 78 | +`cd /lib/modules/$(uname -r)/kernel/drivers/net/wireless/realtek` |
| 79 | + |
| 80 | +Use ls to list out the folders available |
| 81 | +`ls` |
| 82 | + |
| 83 | +My result |
| 84 | +``` |
| 85 | +rtl88x2bu rtl8xxxu |
| 86 | +``` |
| 87 | + |
| 88 | +Once found cd into the folder containing the module you want to load in here I want to load rtl88x2bu |
| 89 | +`cd rtl88x2bu` |
| 90 | + |
| 91 | +Use ls again and find the file name then type modprobe NAME without `.ko` |
| 92 | +`ls` |
| 93 | + |
| 94 | +Result |
| 95 | +``` |
| 96 | +88x2bu.ko |
| 97 | +``` |
| 98 | + |
| 99 | +`sudo modprobe 88x2bu` |
| 100 | + |
| 101 | +If everything works fine no error should pop up |
| 102 | + |
| 103 | +use lsmod to list the loaded modules |
| 104 | + |
| 105 | +`lsmod` |
| 106 | + |
| 107 | +Result |
| 108 | +``` |
| 109 | +Module Size Used by |
| 110 | +88x2bu 4104192 0 |
| 111 | +cfg80211 1093632 1 88x2bu |
| 112 | +``` |
| 113 | + |
| 114 | +And that's it, now attach your usb using usbipd(https://docs.microsoft.com/en-us/windows/wsl/connect-usb#attach-a-usb-device) |
| 115 | + |
| 116 | +after that running iwconfig gives me |
| 117 | +`iwconfig` |
| 118 | + |
| 119 | +Result |
| 120 | +``` |
| 121 | +lo no wireless extensions. |
| 122 | +
|
| 123 | +bond0 no wireless extensions. |
| 124 | +
|
| 125 | +dummy0 no wireless extensions. |
| 126 | +
|
| 127 | +eth0 no wireless extensions. |
| 128 | +
|
| 129 | +tunl0 no wireless extensions. |
| 130 | +
|
| 131 | +sit0 no wireless extensions. |
| 132 | +
|
| 133 | +wlan0 unassociated Nickname:"WIFI@RTL88X2BU" |
| 134 | + Mode:Managed Frequency=2.412 GHz Access Point: Not-Associated |
| 135 | + Sensitivity:0/0 |
| 136 | + Retry:off RTS thr:off Fragment thr:off |
| 137 | + Encryption key:off |
| 138 | + Power Management:off |
| 139 | + Link Quality:0 Signal level:0 Noise level:0 |
| 140 | + Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 |
| 141 | + Tx excessive retries:0 Invalid misc:0 Missed beacon:0 |
| 142 | +``` |
| 143 | + |
| 144 | +And that's it, you can do whatever you want with it as if you were in a normal linux environment! |
| 145 | + |
| 146 | +If you didn't understand something then feel free to make an issue and i'll try to help whenever I can |
| 147 | + |
| 148 | +The rest of the things below is from https://github.com/microsoft/WSL2-Linux-Kernel, didn't remove it just in case someone wanted it for some reason |
| 149 | + |
| 150 | + |
| 151 | + |
| 152 | + |
| 153 | + |
| 154 | + |
| 155 | + |
| 156 | + |
1 | 157 | # Introduction |
2 | 158 |
|
3 | 159 | The [WSL2-Linux-Kernel][wsl2-kernel] repo contains the kernel source code and |
|
0 commit comments