How to access/mount a Windows USB device in WSL
Solution 1:
WSL2 doesn't have much access to the Windows host hardware. This has started to change slightly with Windows 11 and the ability to mount physical drives, but USB is still off-limits to WSL2. Power control, network interface, and other areas are also not accessible from within the virtualized WSL2 environment.
One potential workaround is to share the USB device from Windows to WSL using USBIP. I've never tried this personally, so I can't vouch for it.
This comes from a post in the Home Assistant forums, where folks have been running Home Assistant (a home automation platform) on WSL.
Since most (all?) PC Z-wave interfaces are via USB dongles, one of the key blockers has been how to utilize a USB Z-wave dongle natively from WSL. I'm not going to repeat the whole comment from those forums, but to summarize (and adapt the instructions for "biometric device"):
- Share the device under Windows as a USB/IP device using USB/IP for Windows.
- As of a few weeks ago (at the time of this edit), Microsoft's linux-msft-wsl-5.10.60.1 (and presumably later) kernel release now has USBIP built-in. Before that, you would need to build your own WSL kernel to include the USB/IP module. The Home Assistant post's author also made one available.
- If using a new kernel, set your
.wslconfig
to point to it. At some point, I'm assuming that awsl --update
will automatically update the kernel to a release with USB/IP. -
sudo modprobe
any needed modules for your device. -
usbip list -r $HOSTNAME.local
to (hopefully) see the list of your Windows USB devices and their associated bus id. -
usbip attach -r $HOSTNAME.local -b <bus_id>
with the bus is of your camera.
With that in place, the WSL/Linux system should see your biometric device as a native USB device, allowing you access just as if you were on a native Linux system with a native USB device directly attached.