dorssel / usbipd-win

Windows software for sharing locally connected USB devices to other machines, including Hyper-V guests and WSL 2.
GNU General Public License v3.0
3.56k stars 229 forks source link

can't attach since it keeps saying windows is using the device. can't use --force because it only allows 2 options in the command. #1036

Closed kairin closed 1 week ago

kairin commented 1 week ago

After failure, what is the output of (in WSL):

ls -l /var/run/usbipd-win
╭─ ♥ 07:52 |    comfui
╰─ ls -l /var/run/usbipd-win
total 1204
-r--r--r-- 1 root root    1844 May 25 12:15 README.md
-r-xr-xr-x 1 root root    3271 Jan 17  2024 auto-attach.sh
-r-xr-xr-x 1 root root 1223552 May 25 12:15 usbip

 WSL at   bash MEM: 1.14% | 0/39GB   9ms                                               master ≡  ?1 -1 
╭─ ♥ 07:57 |    comfui
╰─

What is the output of the following commands (as root, so possibly prepend sudo):

mkdir -m 0000 "/var/run/usbipd-win"
mount -t drvfs -o "uid=0;gid=0;umask=222" "C:\Program Files\usbipd-win\WSL" "/var/run/usbipd-win"
 WSL at   bash MEM: 1.15% | 0/39GB   5ms                                               master ≡  ?1 -1 
╭─ ♥ 07:59 |    comfui
╰─ sudo mkdir -m 0000 "/var/run/usbipd-win"
[sudo] password for ks:
mkdir: cannot create directory ‘/var/run/usbipd-win’: File exists

 WSL at   bash MEM: 1.15% | 0/39GB   2s 572ms                                          master ≡  ?1 -1 
╭─ ♥ 08:00 |    comfui
╰─ sudo mount -t drvfs -o "uid=0;gid=0;umask=222" "C:\Program Files\usbipd-win\WSL" "/var/run/usbipd-win"
mount: /var/run/usbipd-win: failed to parse mount options 'rw,uid=0;gid=0;umask=222': Invalid argument.

Originally posted by @dorssel in https://github.com/dorssel/usbipd-win/issues/856#issuecomment-1930189847

image

my issue in powershell:

 usbipd attach --wsl --busid=1-2
usbipd: error: There is no WSL 2 distribution running; keep a command prompt to a WSL 2 distribution open to leave it running.
 usbipd attach --wsl --busid=1-2
usbipd: info: Using WSL distribution 'Ubuntu-24.04' to attach; the device will be available in all WSL 2 distributions.
usbipd: info: Using IP address 192.168.0.1 to reach the host.
WSL usbip: error: Attach Request for 1-2 failed - Device busy (exported)
usbipd: warning: The device appears to be used by Windows; stop the software using the device, or bind the device using the '--force' option.
usbipd: error: Failed to attach device with busid '1-2'.

   pwsh MEM: 13% | 10/79GB   691ms 
╭─ ♥ 07:52 |   
╰─

and then when following the prompt to use --force

usbipd: warning: The device appears to be used by Windows; stop the software using the device, or bind the device using the '--force' option.
usbipd: error: Failed to attach device with busid '1-2'.
 usbipd attach --force --wsl --busid=1-2
Unrecognized command or argument '--force'. 

usbipd-win 4.3.0

Description:
  Attaches a USB device to a client.

  Currently, only WSL is supported. Other clients need to perform an attach using client-side tooling.

  Exactly one of the options '--busid' or '--hardware-id' is required.
kairin commented 1 week ago

https://github.com/dorssel/usbipd-win/issues/856#issuecomment-1931040456

image

 WSL at   bash MEM: 1.15% | 0/39GB   2s 572ms                                          master ≡  ?1 -1 
╭─ ♥ 08:00 |    comfui
╰─ sudo mount -t drvfs -o "uid=0;gid=0;umask=222" "C:\Program Files\usbipd-win\WSL" "/var/run/usbipd-win"
mount: /var/run/usbipd-win: failed to parse mount options 'rw,uid=0;gid=0;umask=222': Invalid argument.

 WSL at   bash MEM: 1.15% | 0/39GB   10ms                                              master ≡  ?1 -1 
╭─ ♥ 08:00 |    comfui
╰─ sudo mount -t drvfs -o "ro,umask=222" "C:\Program Files\usbipd-win\WSL" "/var/run/usbipd-win"

 WSL at   bash MEM: 1.15% | 0/39GB   24ms                                              master ≡  ?1 -1 
╭─ ♥ 08:09 |    comfui
╰─ ls -l /var/run/usbipd-win
total 1204
-r--r--r-- 1 root root    1844 May 25 12:15 README.md
-r-xr-xr-x 1 root root    3271 Jan 17  2024 auto-attach.sh
-r-xr-xr-x 1 root root 1223552 May 25 12:15 usbip

 WSL at   bash MEM: 1.15% | 0/39GB   9ms                                               master ≡  ?1 -1 
╭─ ♥ 08:09 |    comfui
╰─ sudo ls -l /var/run/usbipd-win
total 1204
-r--r--r-- 1 root root    1844 May 25 12:15 README.md
-r-xr-xr-x 1 root root    3271 Jan 17  2024 auto-attach.sh
-r-xr-xr-x 1 root root 1223552 May 25 12:15 usbip

 WSL at   bash MEM: 1.14% | 0/39GB   14ms                                              master ≡  ?1 -1 
╭─ ♥ 08:10 |    comfui
╰─
dorssel commented 1 week ago

The --force option is for the usbipd bind command, not for usbipd attach.

kairin commented 1 week ago

oh. thank you. should have read it more closely.

updated.

PowerShell 7.4.5
Loading personal and system profiles took 1034ms.
 usbipd attach --wsl --busid=1-2
usbipd: info: Using WSL distribution 'Ubuntu-24.04' to attach; the device will be available in all WSL 2 distributions.
usbipd: info: Using IP address 192.168.0.1 to reach the host.
 usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
1-2    1058:262e  USB Attached SCSI (UAS) Mass Storage Device                   Attached
1-9    13d3:3563  MediaTek Bluetooth Adapter                                    Not shared
1-10   0b05:1939  AURA LED Controller, USB Input Device                         Not shared
2-3    3434:0240  USB Input Device                                              Not shared
2-4    1532:008a  USB Input Device, Razer Viper Mini                            Not shared

Persisted:
GUID                                  DEVICE

 lsusb
lsusb: The term 'lsusb' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

   pwsh MEM: 13% | 10/79GB   122ms 
╭─ ♥ 21:06 |   
╰─

and then checked in WSL bash


 WSL at   bash MEM: 1.11% | 0/39GB   0ms                                              master ≡  ?1  1 
╭─ ♥ 21:08 |    comfui
╰─ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 002: ID 1058:262e Western Digital Technologies, Inc. My Passport 262E

 WSL at   bash MEM: 1.1% | 0/39GB   6ms                                               master ≡  ?1  1 
╭─ ♥ 21:08 |    comfui
╰─