You can now connect USB devices in Windows Subsystem for Linux under Windows 11
Microsoft introduced Windows Subsystem for Linux (WSL) a while back, which brought support for running Linux apps straight from your Windows installation. Being such a complex compatibility layer, WSL had some limitations. The initial implementation didn’t even use a full-fledged Linux kernel, so several applications faced compatibility issues. Version 2 made a lot of improvements, but something was still missing: Support for connecting physical USB devices.
If you’re an active user of Windows Subsystem for Linux and want to access USB devices right from the Linux instance running under WSL, then you’ll be happy to know that there has been a significant progress in this front. Thanks to Microsoft’s contributions to the open-source usbipd-win project, you can now enjoy USB passthrough access in WSL. It means end users can perform tasks like flashing Android devices under Windows Subsystem for Linux, which are otherwise not supported by the Linux subsystem.
What is usbipd-win?
The usbipd-win project is all about creating a solution for sharing locally connected USB devices to other machines, including Hyper-V guests and WSL2. However, the official WSL2 Linux kernel used to lack support for the USB/IP protocol, requiring users to build the kernel themselves.
Since WSL kernel version 126.96.36.199, the required parameters are configured out of the box, so no manual recompilation is needed. Microsoft has also contributed a command line interface to the project to both enable a USB device for sharing on Windows and seamlessly attach it from within WSL.
Connect USB devices under Windows Subsystem for Linux
- Run the following command from within WSL:
It should report a kernel version of 188.8.131.52 or later, as shown below:
- Head over the GitHub repo of the usbipd-win project. Then download and install the latest release.
- The latest version of usbipd-win supports silent driver installation, thanks to the Windows Hardware Compatibility Program certified drivers. It also supports Dev channel builds of Windows 11.
- In addition to the release page on GitHub, you can install and update the app using Windows Package Manager CLI (AKA winget).
winget install --interactive --exact dorssel.usbipd-win
- Install the user space tools for USB/IP and a database of USB hardware identifiers. If you’re running Ubuntu on WSL, execute the following command:
sudo apt install linux-tools-5.4.0-77-generic hwdata
- For other distros, consult the documentation of the relevant package management tool.
- Now we need to modify the sudo options to allow the root user to find the
usbipcommand. To do so, edit the
sudo visudoand add
/usr/lib/linux-tools/5.4.0-77-genericto the beginning of
secure_path. It should look like the following:
- Open a new Terminal instance as Administrator and type the following command to list all the USB devices connected to Windows.
usbipd wsl list
- Note down the BUSID value of the USB device you want to attach to WSL. Next, run the following command to initiate the attachment process. You’ll be prompted by WSL for a password to run a sudo command.
usbipd wsl attach --busid <busid>
For example, here we’re attaching an Android device’s Fastboot interface to WSL from the host Windows 11 instance:
- Now open a new WSL 2 instance and run the
lsusbcommand to see available USB devices. It should list the attached device(s).
- That’s it! You can now work with your USB device right from WSL.
When you’re done, you can detach the device using the command shown below. Once again, run it from a Terminal instance running as administrator.
usbipd wsl detach --busid <busid>
Thanks to XDA Senior Member Some_Random_Username for the tip!