close

Home

Windows Client OS

Windows Subsystem for Linux and Hyper-V Get USB Passthrough Support

Author avatar - Russell Smith

Russell Smith

|
Man pointing at gears

Windows Subsystem for Linux (WSL) is a feature in Windows that lets developers test and run Linux binaries directly from their desktop. The beauty of WSL is that there’s no need to switch between your Windows desktop and a virtual machine (VM) to develop Linux code.

For instance, you can open a Linux shell in Windows Terminal or use Visual Studio Code to build, debug, and run Linux apps without installing Linux in a VM. WSL brings developers the convenience of Windows with the power of Linux for app development.

advertisment

If you are new to WSL, learn here how to install Windows Subsystem for Linux 2 and Ubuntu.

WSL has been generally welcomed by developers. And for most, it has proven more than adequate for their development needs on Windows. But developers working on IoT devices, where apps are developed for embedded Linux distributions, were left out in the cold because these devices connect to PCs via USB, which until now, wasn’t supported by WSL.

For more information on how to run Linux GUI apps using WSL, check out How to Install Linux GUI Apps in Windows 10 and Windows 11 with WSL on Petri.

Microsoft announced earlier this month that there’s now WSL support for USB device passthrough, albeit not natively. The functionality has been enabled by an open-source project called usbipd-win-project that lets developers use WSL in common scenarios that require USB connectivity, like flashing an Arduino or using a smartcard reader.

advertisment

The project was originally started by Frans van Dorsselaer, a system architect based in Holland. Then it was picked up by a summer intern at Microsoft, Nelson Daniel Troncoso, a researcher and PhD student at Penn State University, who is responsible for the project in its current form.

How does USB device passthrough support work for WSL 2 and Hyper-V?

USBIPD works by using the USB/IP protocol to send USB traffic over the virtual network interface between Windows and WSL 2 or Hyper-V. Microsoft says that support for USB/IP has been in the Linux kernel since 2009 but that recent updates to Linux have made USB/IP easier to use in WSL.

Linux includes a USB/IP client, but Windows doesn’t natively have a USB/IP server. USBIPD fills that gap. Microsoft contributed the USBIPD command line tool to the project for enabling USB device sharing in Windows and for attaching devices in WSL.

How to use USB devices in Hyper-V and WSL 2

According to the project’s GitHub page, USBIPD works on Windows 8 and Windows Server 2012 or newer. The binaries install a service called USBIPD Device Host, a command line tool, and a Windows Firewall rule.

advertisment

Installing the binaries is as easy as running the winget package manager command below:

winget install --interactive --exact dorssel.usbipd-win

You might be required to reboot your PC.

Windows Subsystem Linux Hyper-V USB passthrough

Windows Subsystem Linux and Hyper-V get USB passthrough support (Image Credit: Microsoft)

USB devices are not shared with USBIPD by default. To share a USB device, you should run the usbipd command line tool from a prompt with administrator privileges.

usbipd --help
usbipd list
usbipd bind --busid=<BUSID>

Share and connect a USB device to WSL 2

The above command works for Hyper-V guest VMs. But if you want to share and connect a USB device to WSL 2, it’s a bit more complicated. Microsoft provides detailed instructions for Windows 11 on its website for setting up USB device passthrough support in WSL 2.

For a complete walkthrough of how to connect USB devices to WSL 2, check out the video below from Microsoft.

Related articles

Article saved!

Access saved content from your profile page. View Saved