Connect USB devices | Microsoft Learn
使用开源工具usbipd,可以让usb设备连接WSL
https://github.com/dorssel/usbipd-win
usbipd list 可以查看连接到win上的设备。
把USB设备从win转移到WSL需要执行下面两个指令。
usbipd bind --busid <BUSID>
usbipd attach --wsl --busid <busid>
Before attaching the USB device, the command
usbipd bind
must be used to share the device, allowing it to be attached to WSL. This requires administrator privileges. Select the bus ID of the device you would like to use in WSL and run the following command. After running the command, verify that the device is shared using the commandusbipd list
again.
To attach the USB device, run the following command. (You no longer need to use an elevated administrator prompt.) Ensure that a WSL command prompt is open in order to keep the WSL 2 lightweight VM active. Note that as long as the USB device is attached to WSL, it cannot be used by Windows. Once attached to WSL, the USB device can be used by any distribution running as WSL 2. Verify that the device is attached usingusbipd list
. From the WSL prompt, runlsusb
to verify that the USB device is listed and can be interacted with using Linux tools.