IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    wsl2 连接 USB 设备

    Hacper\'s Blog发表于 2023-10-11 00:41:49
    love 0

    windows 配置

    下载安装 usbipd-win。

    wsl 配置

    安装 USBIP 工具和硬件数据库

    输入 sudo apt install linux-tools-generic hwdata 和 sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/*-generic/usbip 20

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    
    hacper@LAPTOP-0RHP1TGD:~$ sudo apt install linux-tools-generic hwdata
    
    Reading package lists... Donel /usr/local/bin/usbip usbip /usr/lib/linux-tools/*-generic/usbip 20
    Building dependency tree
    Reading state information... Done
    Get:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-tools-5.4.0-164 amd64 5.4.0-164.181 [5606 kB]
    Get:4 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-tools-5.4.0-164-generic amd64 5.4.0-164.181 [1996 B]
    Get:5 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-tools-generic amd64 5.4.0.164.161 [2460 B]
    Fetched 5833 kB in 6s (940 kB/s)
    Selecting previously unselected package hwdata.
    (Reading database ... 50195 files and directories currently installed.)
    Preparing to unpack .../hwdata_0.333-1_all.deb ...
    Unpacking hwdata (0.333-1) ...
    Selecting previously unselected package linux-tools-common.
    Preparing to unpack .../linux-tools-common_5.4.0-164.181_all.deb ...
    Unpacking linux-tools-common (5.4.0-164.181) ...
    Selecting previously unselected package linux-tools-5.4.0-164.
    Preparing to unpack .../linux-tools-5.4.0-164_5.4.0-164.181_amd64.deb ...
    Unpacking linux-tools-5.4.0-164 (5.4.0-164.181) ...
    Selecting previously unselected package linux-tools-5.4.0-164-generic.
    Preparing to unpack .../linux-tools-5.4.0-164-generic_5.4.0-164.181_amd64.deb ...
    Unpacking linux-tools-5.4.0-164-generic (5.4.0-164.181) ...
    Selecting previously unselected package linux-tools-generic.
    Preparing to unpack .../linux-tools-generic_5.4.0.164.161_amd64.deb ...
    Unpacking linux-tools-generic (5.4.0.164.161) ...
    Setting up hwdata (0.333-1) ...
    Setting up linux-tools-common (5.4.0-164.181) ...
    Setting up linux-tools-5.4.0-164 (5.4.0-164.181) ...
    Setting up linux-tools-5.4.0-164-generic (5.4.0-164.181) ...
    Setting up linux-tools-generic (5.4.0.164.161) ...
    Processing triggers for man-db (2.9.1-1) ...
    
    hacper@LAPTOP-0RHP1TGD:~$ sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/*-generic/usbip 20
    update-alternatives: using /usr/lib/linux-tools/5.4.0-164-generic/usbip to provide /usr/local/bin/usbip (usbip) in auto mode
    

    连接 USB 设备到 wsl

    管理员权限打开 power shell, 输入:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    
    PS C:\Users\hacper> usbipd wsl list
    
    BUSID  VID:PID    DEVICE                                                        STATE
    2-1    1ea7:0066  USB 输入设备                                                  Not attached
    2-5    13d3:5471  XiaoMi Webcam                                                 Not attached
    2-7    10a5:9200  FPC Fingerprint Reader (Disum), FPC Sensor Controller FW ...  Not attached
    2-10   8087:0026  英特尔(R) 无线 Bluetooth(R)                                   Not attached
    2-15   1058:25f3  USB Attached SCSI (UAS) 大容量存储设备                        Not attached
    
    usbipd: warning: USB filter 'USBPcap' is known to be incompatible with this software; 'bind --force' will be required.
    
    PS C:\Users\hacper> usbipd wsl attach --busid 2-15
    
    usbipd: info: Using default WSL distribution 'Ubuntu'; specify the '--distribution' option to select a different one.
    usbipd: warning: USB filter 'USBPcap' is known to be incompatible with this software; 'bind --force' will be required.
    
    PS C:\Users\hacper> usbipd wsl list
    
    BUSID  VID:PID    DEVICE                                                        STATE
    2-1    1ea7:0066  USB 输入设备                                                  Not attached
    2-5    13d3:5471  XiaoMi Webcam                                                 Not attached
    2-7    10a5:9200  FPC Fingerprint Reader (Disum), FPC Sensor Controller FW ...  Not attached
    2-10   8087:0026  英特尔(R) 无线 Bluetooth(R)                                   Not attached
    2-15   1058:25f3  USB Attached SCSI (UAS) 大容量存储设备                        Attached - WSL
    
    usbipd: warning: USB filter 'USBPcap' is known to be incompatible with this software; 'bind --force' will be required.
    PS C:\Users\hacper>
    

    wsl 中设置

    1
    2
    3
    4
    5
    6
    
    hacper@LAPTOP-0RHP1TGD:~$ lsusb
    
    Bus 002 Device 002: ID 1058:25f3 Western Digital Technologies, Inc. My Passport 25F3
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    hacper@LAPTOP-0RHP1TGD:~$
    

    资料

    • 连接 USB 设备
    • usbipd-win


沪ICP备19023445号-2号
友情链接