Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cweiland/d64ac96e01e1d50d4e4cff193850051d to your computer and use it in GitHub Desktop.
Save cweiland/d64ac96e01e1d50d4e4cff193850051d to your computer and use it in GitHub Desktop.
#!/bin/bash
WINDOWS_USER="<windows_user>"
sudo apt update
sudo apt install build-essential flex bison libssl-dev libelf-dev bc libncurses-dev autoconf libudev-dev libtool dwarves -y
WSLKERNEL=$(uname -a | cut -d " " -f3 | cut -d "-" -f1)
CHECKOUT_DIR="linux-msft-wsl-${WSLKERNEL}"
export WSLKERNEL
export CHECKOUT_DIR
export WINDOWS_USER
git clone "https://github.com/microsoft/WSL2-Linux-Kernel.git" --depth=1 -b "${CHECKOUT_DIR}"
cd "WSL2-Linux-Kernel" || exit
zcat /proc/config.gz > .config
sudo make -j"$(nproc)" KCONFIG_CONFIG=Microsoft/config-wsl CONFIG_USB_STORAGE=m USB_SUPPORT=m
sudo make -j"$(nproc)" KCONFIG_CONFIG=Microsoft/config-wsl CONFIG_USB_STORAGE=m USB_SUPPORT=m modules
sudo make -j"$(nproc)" KCONFIG_CONFIG=Microsoft/config-wsl CONFIG_USB_STORAGE=m USB_SUPPORT=m modules_install
#sudo make -j"$(nproc)" KCONFIG_CONFIG=Microsoft/config-wsl CONFIG_USB_STORAGE=m USB_SUPPORT=m install
cp "arch/x86/boot/bzImage" "/mnt/c/Users/${WINDOWS_USER}/usbip-bzImage"
echo "[wsl2]
kernel=c:\\users\\${WINDOWS_USER}\\usbip-bzImage" > "/mnt/c/Users/${WINDOWS_USER}/.wslconfig"
echo "Restart your WSL2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment