The inability to pass through a connected USB device from a Hyper-V host to a virtual machine is one of the major shortcomings of the Microsoft hypervisor. You can use the open-source project usbipd-win to solve this problem (https://github.com/dorssel/usbipd-win). The usbipd-win utility allows you to pass through (redirect USB device or key including HASP) over the network from a Windows host to any Hyper-V virtual machine, remote computer running Linux, Windows, or WSL2.
To redirect USB devices over the network, the usbipd-win implements the USB over IP protocol.
You can install the usbipd-win server on a Windows 10/11 device using the WinGet package manager:
winget install --id=dorssel.usbipd-win -e
On Windows Server 2019/2016 you can also download and install the MSI package manually. For example usbipd-win_2.4.1.msi (https://github.com/dorssel/usbipd-win/releases).
After installation, the new usbipd (USBIP Device Host) service will appear in Windows.
Open a command prompt and list available USB devices on your host:
usbipd list
To share a USB device, run the command:
usbipd bind --busid <busid>
For example:
usbipd bind --busid=7-1
Now you can access this USB device over the network from another Linux or Windows host. TCP port 3240 is used for connection (make sure it is open in Windows Defender Firewall).
If you want to redirect a USB device from a Windows host to Linux, you will need to install additional client packages:
-
- On Ubuntu and Debian:
$ sudo apt install usbip hwdata usbutils
- On Ubuntu and Debian:
- On RPM-based Linux distros (CentOS/RHEL/Oracle Linux):
$ sudo yum install kmod-usbip usbip-utils hwdata
You can now list the USB devices that are shared on the remote Windows (Hyper-V) host:
$ usbip list --remote=192.168.0.10
In order to mount a specific USB device to your host via the IP network, run the command
$ sudo usbip attach -remote=192.168.0.10 --busid=7-1
If you need to connect a shared USB device to WSL 2, first install the necessary packages on your WSL distribution (e.g. Ubuntu):
$ sudo apt install linux-tools-5.4.0-77-generic hwdata
$ sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/5.4.0-77-generic/usbip 20
Then use the following commands to list the USB devices and mount one of them:
usbipd wsl list
usbipd wsl attach --busid 7-1
Check to see if the USB device is available:
$ lsusb
To disconnect a USB device:
usbipd wsl detach --busid 7-1
You must install a special client agent, usbip.exe, if you need to pass a USB device through the network to another Windows host (https://github.com/cezanne/usbip-win)
To automatically connect a USB device over the network when Windows starts, add the following command to the Windows Task Scheduler
usbip.exe attach -r 192.168.0.10 -b 7-1