将 USB/IP 与 WSL 结合使用时“未找到内核的 usbipd”

com*_*vip 12 usb kernel windows-subsystem-for-linux

我正在尝试将 USB 设备连接到在 WSL2 下运行的 Ubuntu 20.04 发行版。

问题是当我运行该usbip命令时,它给出以下消息:

WARNING: usbipd not found for kernel 5.10.16.3-microsoft

  You may need to install the following packages for this specific kernel:
    linux-tools-5.10.16.3-microsoft-standard-WSL2
    linux-cloud-tools-5.10.16.3-microsoft-standard-WSL2

  You may also want to install one of the following packages to keep up to date:
    linux-tools-standard-WSL2
    linux-cloud-tools-standard-WSL2
Run Code Online (Sandbox Code Playgroud)

我尝试这样做:

$ sudo apt install linux-tools-5.10.16.3-microsoft-standard-WSL2
Run Code Online (Sandbox Code Playgroud)

...但这行不通。它返回以下内容:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-tools-5.10.16.3-microsoft-standard-WSL2
E: Couldn't find any package by glob 'linux-tools-5.10.16.3-microsoft-standard-WSL2'
Run Code Online (Sandbox Code Playgroud)

我一直在谷歌搜索如何安装它们,但我找不到任何有关此的信息。

笔记:

  • Ubuntu安装大约是2个月前安装的。
  • 我正在使用 WSL2
  • uspip由 PowerShell调用usbipd wsl attach -b 2-2,因为我正在尝试将 USB 设备连接到 Ubuntu
  • 内核版本5.10.16.3-microsoft-standard-WSL2

Not*_*1ds 7

根据WSL2 USB/IP 先决条件,您需要WSL2 5.10.60.1 内核或更高版本。这是第一个添加 USB/IP 支持的版本。

假设您运行的是 Windows 11,您只需wsl --update通过管理员 PowerShell 即可获取最新版本。然后wsl --shutdown重新启动。

您还可以从 WSL2 内核源代码构建自己的内核(确保指定 WSL2 内核配置选项),但大多数人不需要走这条路。

请注意,如果您运行的是 Windows 10,则将适用不同的说明。

继续按照之前链接的文档上的说明进行操作,您将看到需要安装的软件包是:

sudo apt install linux-tools-5.4.0-77-generic hwdata
sudo update-alternatives --install /usr/local/bin/usbip usbip $(command -v ls /usr/lib/linux-tools/*/usbip | tail -n1) 20
Run Code Online (Sandbox Code Playgroud)

此时,PowerShellusbipd wsl attach应该可以工作了。