It is now possible to connect USB devices in WSL and work with them directly. Thanks to Microsoft's contributions to open-source usbipd-win project, you can do a variety of tasks which weren't available in WSL, like flashing an Arduino or accessing a smartcard reader.
The feature requires you to have the second gen of WSL with a kernel version 188.8.131.52 or later.
Usbipd-win is a software for sharing locally connected USB devices to other machines, including Hyper-V guests and WSL 2. It supports silent driver installation thanks to use of Microsoft Hardware Compatibility Publisher drivers. It also supports Dev channel builds, so you can try it even if you run a pre-release Windows 11. Finally, in addition to the release page on GitHub, you can install and update the app with
Here's how to use it to connect USB devices under WSL.
Connect USB devices in WSL
- Head over this GitHub page, download and install the latest app version.
- Open your Ubuntu WSL 2 instance and type
sudo apt install linux-tools-5.4.0-77-generic hwdata.
- Now, modify the sudo options to allow the
rootuser to run the usbip command. For that, type
sudo visudoand hit Enter.
- Add /usr/lib/linux-tools/5.4.0-77-generic to the beginning of secure_path. You will get something like this:
- Open a new command prompt as administrator.
- Type usbipd wsl list and hit Enter.Note the BUS ID value for the USB device you want to attach to WSL.
- Now, run this command:
usbipd wsl attach --busid <busid>. Substitute the <busid> value with the one you noted.
- Finally, open your WSL 2 instance and run the lsusb command to see available USB devices. It should list your attached device.
You are done!
You can now work with your USB device right from WSL.
When finished, detach the device using the
usbipd wsl detach --busid <busid>. Again, run it from a command prompt running as administrator.
You can learn more on how it works in the official announcement.
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options: