Windows Client OS

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

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.

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.

Sponsored Content

Passwords Haven’t Disappeared Yet

123456. Qwerty. Iloveyou. No, these are not exercises for people who are brand new to typing. Shockingly, they are among the most common passwords that end users choose in 2021. Research has found that the average business user must manually type out, or copy/paste, the credentials to 154 websites per month. We repeatedly got one question that surprised us: “Why would I ever trust a third party with control of my network?

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.

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.

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 Topics:


Don't have a login but want to join the conversation? Sign up for a Petri Account

Comments (0)

Leave a Reply

IT consultant, Contributing Editor @PetriFeed, and trainer @Pluralsight. All about Microsoft, Office 365, Azure, and Windows Server.
Live Webinar - Thursday, December 2nd! Active Directory Masterclass: AD Configuration Strategies for Stronger SecurityREGISTER NOW - Thursday, December 2, 2021 @ 1 pm ET

Active Directory (AD) is leveraged by over 90% of enterprises worldwide as the authentication and authorization hub of their IT infrastructure—but its inherent complexity leaves it prone to misconfigurations that can allow attackers to slip into your network and wreak havoc. 

Join this session with Microsoft MVP and MCT Sander Berkouwer, who will explore:

  • Whether you should upgrade your domain controllers to Windows Server
    2019 and beyond
  • Achieving mission impossible: updating DCs within 48 hours
  • How to disable legacy protocols and outdated compatibility options in
    Active Directory

Sponsored by: