You can now connect USB devices in WSL

WSL In Microsoft Store

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 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 winget.

Here's how to use it to connect USB devices under WSL.

Connect USB devices in WSL

  1. Head over this GitHub page, download and install the latest app version.
  2. Open your Ubuntu WSL 2 instance and type sudo apt install linux-tools-5.4.0-77-generic hwdata.
  3. Now, modify the sudo options to allow the root user to run the usbip command. For that, type sudo visudo and hit Enter.
  4. Add /usr/lib/linux-tools/5.4.0-77-generic to the beginning of secure_path. You will get something like this: Defaults secure_path="/usr/lib/linux-tools/5.4.0-77-generic:/usr/local/sbin:...".
  5. Open a new command prompt as administrator.
  6. Type usbipd wsl list and hit Enter.Note the BUS ID value for the USB device you want to attach to WSL.
  7. Now, run this command: usbipd wsl attach --busid <busid>. Substitute the <busid> value with the one you noted.
  8. 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.

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

One thought on “You can now connect USB devices in WSL”

  1. I just want to do the reverse! You might be amazed where did I find usb from wsl first. Calm down I just mount it from remote computer to my wsl machine. Then I want to mount to windows host. I have full reason to do that.

Leave a Reply

Your email address will not be published.

Exit mobile version
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.