Unlocking USB Device Access in Windows Subsystem for Linux (WSL)

Microsoft’s Windows Subsystem for Linux (WSL) has been a game-changer, allowing users to seamlessly run Linux applications within their Windows environment without the need for virtual machines. However, despite its many advancements, WSL had limitations, particularly when it came to connecting physical USB devices. Fortunately, there have been significant developments in this area, thanks to Microsoft’s contributions to the open-source usbipd-win project. In the following article, we will discuss unlocking USB device access in Windows Subsystem for Linux (WSL) under Windows 11.

Table of Contents

Exploring usbipd-win

The usbipd-win project’s mission is to enable the sharing of locally connected USB devices with other machines, including Hyper-V guests and WSL2. Previously, users had to go through the hassle of manually building the kernel because the official WSL2 Linux kernel lacked support for the USB/IP protocol. However, with WSL kernel version and later, these necessary configurations are prebuilt, eliminating the need for manual compilation. Additionally, Microsoft has introduced a command-line interface to the project, simplifying the process of sharing and attaching USB devices from within WSL.

How to Connect USB Device in WSL

For users eager to access USB devices directly from their WSL instance, here’s a step-by-step guide:

  1. Check Compatibility: Ensure that you’re running Windows 11 and have installed all WSL updates. USB device pass-through requires WSL 2.
  2. Verify Kernel Version: Within your WSL instance, execute the command uname -a. If the kernel version is or higher, you’re good to proceed.
  3. Update Kernel (If Necessary): In case your kernel version is older, you can update it using the following commands:
wsl --shutdown

wsl –update
  1. Install usbipd-win: Visit the GitHub repository of the usbipd-win project, download the latest release, and install it. Alternatively, you can use the Windows Package Manager CLI (winget) with the command:
winget install --interactive --exact dorssel.usbipd-win
  1. Install USB Tools: If you’re running Ubuntu on WSL, use the following commands to install the required tools:
sudo apt install linux-tools-virtual hwdata

sudo update-alternatives --install /usr/local/bin/usbip usbip `ls /usr/lib/linux-tools/*/usbip | tail -n1` 20
  1. Adjust sudoers (If Needed): If the symbolic link created in the previous step doesn’t work, you may need to manually edit the /etc/sudoers file to allow the root user to locate the usbip command.
  2. List USB Devices: Run the command usbipd wsl list in a new Terminal instance with Administrator privileges. Take note of the BUSID value of the USB device you intend to attach.
  3. Attach USB Device: Execute the following command, replacing <busid> with the value you noted earlier. You’ll be prompted to enter a password to run a sudo command.
usbipd wsl attach --busid <busid>
  1. Confirm Connection: Open a fresh WSL 2 instance and run the ‘lsusb’ command to view the available USB devices. You should now see the attached device(s).
  2. Detaching USB Device: To detach the USB device, use the following command in a Terminal instance running as an administrator:
usbipd wsl detach --busid <busid>

GUI Option: wsl-usb-gui

For those who prefer a graphical user interface (GUI), consider using wsl-usb-gui—an unofficial GUI wrapper for usbipd-win. This tool simplifies USB device listing and management between the host OS and the WSL instance.

  1. Ensure Compatibility: Confirm that you have the latest version of usbipd-win installed, and ensure your WSL kernel is up-to-date.
  2. Download wsl-usb-gui: Visit the project’s GitLab releases page, download the latest installer, and run it.
  3. Installer Configuration: The installer checks for prerequisites and attempts to set them up if necessary. It’s advisable to keep everything updated manually to avoid unexpected compatibility issues.
  4. Launch wsl-usb-gui: Look for the “WSL USB” shortcut in the Start menu and run the app from there.
  5. Managing USB Devices: Utilize the GUI to effortlessly list, attach, and detach USB devices.

With USB pass-through support in WSL, you gain the ability to unlock USB Device Access in WSL. Whether you opt for the command line or a user-friendly GUI, these tools empower you to seamlessly interact with USB devices. For further exploration and advanced configurations, consult Microsoft’s official documentation on connecting USB devices under WSL and refer to the usbipd-win GitHub Wiki section. Unleash the potential of your WSL environment today!

Also Read: Confused by APN Settings? Here’s how to change them

Leave a Comment