How to install package for Ubuntu kernel on WSL2

From the WSL2 USB/IP Prerequisites, you'll need the WSL2 5.10.60.1 kernel or higher. That's the first release that added USB/IP support.

Assuming that you are running Windows 11, you can simply wsl --update from an Administrator PowerShell in order to pull in the latest. Then wsl --shutdown and restart.

You could also build your own from the WSL2 kernel sources (making sure to specify the WSL2 kernel config options), but most people won't need to go this route.

Note that if you are running Windows 10, different directions will apply.

Continue following the directions on the previously linked doc, and you'll see that the packages you need installed are:

sudo apt install linux-tools-5.4.0-77-generic hwdata

Finally, sudo visudo per the instructions to add the correct /usr/lib/linux-tools/5.4.0-77-generic directory to the beginning of the sudo secure_path.

At that point, the PowerShell usbipd wsl attach should work.