Attach USB in WSL2

date
Mar 29, 2023
slug
wsl2-usb
status
Published
tags
Others
summary
use WSL to flash your devices
type
Post

Windows

install usbipd
list usb
attach usb

WSL

install usbip, lsusb
 

AI says:

To detach the USB device, run usbipd wsl detach --busid 1-19. Once the device is detached, it can be safely removed from the computer. Note that if the USB device was mounted in WSL, it must be unmounted before detaching it.
To use the USB device in WSL2, it must first be attached to Windows using usbipd. Once the device is attached, list the available USB devices using the command lsusb. Select the device to use and attach it to WSL2 using the command sudo usbip attach -r <remote-host> -b <bus-id>. The USB device should now be usable within WSL2. When finished, detach the device using the command sudo usbip detach -p <port-number>.
Here are the steps to use USB devices in WSL2:
  1. Install usbip and usbutils in WSL2 using the command yay -S usbip usbutils.
  1. Attach the USB device to Windows using usbipd wsl attach --busid <busid>.
  1. List the available USB devices using the command lsusb.
  1. Select the device to use and attach it to WSL2 using the command sudo usbip attach -r <remote-host> -b <bus-id>.
  1. The USB device should now be usable within WSL2.
  1. When finished, detach the device using the command sudo usbip detach -p <port-number>.
Note that if the USB device was mounted in WSL2, it must be unmounted before detaching it.
I hope this helps! Let me know if you have any other questions or concerns.

© Ric Li 2021 - 2024