Usbipd-win is an open-source project that allows sharing locally connected USB devices with other machines, including Hyper-V guests and WSL 2. It provides access to USB devices by using network connectivity over TCP port 3240.

The latest release of usbipd-win (v1.3.0) includes the following new features and enhancements:

  • Adds support for devices with REMOTE_WAKE, useful for Bluetooth devices
  • Adds support for selecting device configurations other than the first configuration
  • Adds support for WSL 2 on older Windows 10 versions (>= 1903)
  • Improves compatibility with certain USB hubs and devices
  • Improves device descriptions
  • Enhances the performance of device enumeration
  • Reduces the installation footprint

Installing usbipd-win ^

Installation of usbipd-win is straightforward and easy using one of the following:

  • An MSI file available for download from the usbipd-win GitHub site
  • Using the winget utility and pulling it directly from the winget repository using the command:
    winget install --interactive --exact dorssel.usbipd-win

The recommended installation of usbipd-win using the winget command requires the interactive switch to prevent the machine from rebooting unexpectedly. The behavior of the interactive session is identical to downloading the MSI file manually and running the installer.

Using winget to install the usbipd win in Windows 11

Using winget to install the usbipd win in Windows 11

The installation of usbipd-win creates a firewall rule called usbipd to allow all local subnets to connect to the service. However, this rule can be modified to granularly control access.

The usbipd firewall rule created after installation

The usbipd firewall rule created after installation

You can now open the Windows Services console and see the newly installed USBIP Device Host service listed.

Viewing the usbipd win service after installation

Viewing the usbipd win service after installation

When running the usbipd command line utility without any arguments, it shows all available options.

Running the usbipd command line utility

Running the usbipd command line utility

Listing and sharing USB devices with usbipd-win ^

Using the usbipd command-line tool, we can list the available USB devices and share them. First, we use the command:

usbipd list
Listing available USB devices using usbipd

Listing available USB devices using usbipd

Based on the BUSID presented for a specific USB device, use the following command to share it:

usbipd bind --busid <busid>
Running the usbipd bind command

Running the usbipd bind command

Attaching the USB to WSL 2 using usbipd-win ^

There are supplied commands in the usbipd utility in Windows to automatically connect a USB drive to your WSL instances. I am running WSL 2 with an Ubuntu distribution. You can list the WSL-attached USB devices with the command:

usbipd wsl list
Running the usbipd wsl list command

Running the usbipd wsl list command

There are a few extra steps you need to perform in your WSL 2 instance per the usbipd Wiki documentation for WSL 2. These include:

sudo apt install linux-tools-5.4.0-77-generic hwdata
Installing linux tools 5.4.0 77 generic hwdata for usbipd

Installing linux tools 5.4.0 77 generic hwdata for usbipd

Next, add /usr/lib/linux-tools/5.4.0-77-generic to the beginning of secure\_path in the sudoers file.
Configuring the secure path in the sudoers file

Configuring the secure path in the sudoers file

After performing these steps, I ran into the following error:

"WSL distribution cannot be reached via the WSL virtual switch"

when running the command:

usbipd wsl attach --busid 4-2
WSL distribution cannot be reached via the WSL virtual switch

WSL distribution cannot be reached via the WSL virtual switch

However, the workaround in my case, as noted here, was to run the command manually from within the WSL 2 environment. Oddly enough, I was using a Debian variant of Linux that was supposed to work.

sudo usbip attach -remote=192.168.1.234 --busid=4-2

In the command above, the IP address is the IPv4 address of my host workstation running WSL 2. After running the command in the WSL 2 environment, as you can see, the "SanDisk Corp. Ultra USB 3.0" is successfully listed when running the lsusb command.

Running the usbip attach remote command from within WSL 2

Running the usbip attach remote command from within WSL 2

System requirements ^

It is supported in Windows 8 client OSes and newer, and Windows Server 2012 and newer operating systems.

Final thoughts ^

The usbipd-win utility is an interesting way to solve the challenges associated with accessing files on removable media, such as a USB drive. Instead of "jumping through hoops" to have USB access, usbipd-win makes this process very straightforward.

Subscribe to 4sysops newsletter!

As shown in the WSL 2 example, you can easily mount USB storage attached to your Windows host inside your WSL 2 environment. While I ran into a couple of challenges with the implementation, the workarounds were easy.

0 Comments

Leave a reply

Your email address will not be published.

*

© 4sysops 2006 - 2022

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account