-
-
Save itsdotscience/6431647a15c9ff626e780066845bb6fe to your computer and use it in GitHub Desktop.
| #!/bin/bash | |
| export WSLKERNEL=`uname -a | cut -d " " -f3 | cut -d "-" -f1` | |
| export CHECKOUT_DIR=`linux-msft-wsl-$WSLKERNEL` | |
| git clone https://github.com/microsoft/WSL2-Linux-Kernel.git --depth=1 -b $CHECKOUT_DIR | |
| cd $WSLKERNEL | |
| sudo make -j$(nproc) KCONFIG_CONFIG=Microsoft/config-wsl CONFIG_USB_STORAGE=m CONFIG_USB_UAS=m | |
| sudo make -j$(nproc) KCONFIG_CONFIG=Microsoft/config-wsl CONFIG_USB_STORAGE=m CONFIG_USB_UAS=m modules | |
| sudo make -j$(nproc) KCONFIG_CONFIG=Microsoft/config-wsl CONFIG_USB_STORAGE=m CONFIG_USB_UAS=m modules_install | |
| cp arch/x86/boot/bzImage wsl-$WSLKERNEL | |
| echo "Copy the above to the root of your USERPROFILE on the Windows sdie then Add in the [wsl] section of your .wslconfig the following, doubling all | |
| kernel=c:\\users\\username\\wsl-$WSLKERNEL | |
| Then run wsl --shutdown from Windows, wait a minut or so and star wsl again. Once you have your usb device passed you should see the storage device if not, try on the wsl side: modprobe usb-storage; modprobe uas" |
@Komorebi-E
why did you comment out the make commands?
may be also worth asking: adding "m" for module makes it avail for usb mass storage, but not via modprobe?
@rs38 Commenting was from testing the \ to get the right output. I've removed the comments on the make commands - thank you for pointing it out.
Correct, it is a available fir USB mass storage. WSL2 with a custom built kernel cannot load modules with modprobe as the loadable module support is disabled when WSL2 is configured this way.
@Komorebi-E what's strange: to make the USB mass storage actually work with USBIPD and that custom kernel, I have to execute modprobe vhci_hcd in WSL2, which succeeds.
(and docker is failing)
Install build-essential flex bison libssl-dev libelf-dev libncurses5-dev git bc pahole to get the dependencies.
This worked for me.
For SD Card / MMC support I needed to add
CONFIG_MMC=mfor USB devices with SD/MMC card's to show up forlsblk.This includes the suggestions from @StoaferP and adds the conditional for if the Microsoft WSL2 kernel has already been cloned.
Note that from the WSL2 Kernel README, modules cannot be loaded with
modprobe- so removed it from the instructions.