0

I have attached and detached my USB webcam to/from Ubuntu 20.04 in WSL2 with usbipd-win using the instructions in Connect USB Devices. From PowerShell:

usbipd wsl attach --busid 2-4

Once I'm done, I detach with:

usbipd wsl detach --busid 2-4

However, when I try a second time to attach the same USB webcam device using the same command:

usbipd wsl attach --busid 2-4

... the PowerShell console shows this error:

usbip: error: Attach Request for 2-4 failed - Device busy (exported)

What does it means that the USB webcam is busy?

Why could the webcam be busy despite the fact I have detached it before?

Hi, if I try in WSL2 :

~$ sudo usbip port 

It shows :

Imported USB devices

====================

If I try in Power Shell :

PS C:\Windows\System32> usbipd wsl list 

       

BUSID      DEVICE                                                STATE


2-2 USBIP Shared Device, NexiGo N950P 4K Webcam, NexiGo N950P... Not attached

Also if I try PS, ( NOTICE without "wsl" ) :

PS C:\Windows\System32> usbipd unbind --busid 2-2   

now it doesn't give me an error simply it doesn't works

if I try:

PS C:\Windows\System32> usbipd bind --busid 2-2

usbipd: info: Device with busid '2-2' was already shared.

9
  • Hello and Welcome to Unix & Linux Stack! Unfortunately, I'm having a very difficult time understanding parts of your question. You'll need to edit it to make it more clear before anyone can likely help you with this. (a) You say "WSL2 PowerShell", but "WSL2" and "PowerShell" are two different things entirely. When using USB/IP, some commands should be run in PowerShell and some in Ubuntu/WSL2 (b) Related - you say that you are attaching via "PowerShell", but that command should be done via Ubuntu on WSL. The bind command (which you don't show) should be done in PowerShell. Apr 21, 2022 at 19:40
  • (c) The last sentence just doesn't make sense -- "Why the webcam could be busy despite the fact I have detached it before the webcam?" -- The word "it" here can only refer to "the webcam", which makes this read, "detached the webcam before the webcam". I understand that English is not your native language, but we'll need to improve the question in order to help you, most likely. Thanks! Apr 21, 2022 at 19:42
  • Hi, I'm sorry for my english, I'm doing my best to improve my question. I would say that this type of error occured while a Linux distribution Ubuntu 20.4 was running on WSL2, and I have tried to connect a usb device ( a webcam ) to Ubuntu using the USBIP tools , and writing the istructions in the Power Shell. I have also revised my question to make it better.. i hope now the issue and my question could be more clear and coherent. Thank you again for your suggestions and if you could help me understand my issue.
    – DanielePP
    Apr 21, 2022 at 22:55
  • No need to apologize for your English - We'll get through it :-). Thank you for the edits -- They do help. And apologies on my part, though - I forgot that for most people the commands are all run from PowerShell. I usually run the attach on the Linux/WSL2 end since I don't use USB/IP in my default distribution. I've seen the error you are getting before, but I'm not able to reproduce it right now -- I'll keep trying and come back with additional questions if needed. Thanks! Apr 22, 2022 at 2:25
  • Ah, I remember now - I saw it when using an Android device in this Super User question. I think some process on the Linux end of things has the connection open, so the PowerShell detach doesn't fully take, but I'm not quite sure yet. Apr 22, 2022 at 3:22

3 Answers 3

1

I don't have an answer for you yet, but we're getting beyond what can be explained in the comments, so I'm going to add some info here while we figure this out.

You mention in the comments trying:

usbipd wsl unbind --busid <busid>

... in PowerShell and receiving an error. That's to be expected. Run:

$ usbipd wsl -h
usbipd-win 2.2.0

Description:
  Convenience commands for attaching and detaching devices to Windows Subsystem for Linux.

Usage:
  usbipd wsl [command] [options]

Options:
  -?, -h, --help  Show help and usage information

Commands:
  attach  Attach a USB device to a WSL instance
  detach  Detach a USB device from a WSL instance
  list    List USB devices

So you can see the only valid commands that can follow usbipd are attach, detach, and list.

As it says, these are "convenience commands". They are shorthand:

  • usbipd wsl attach -b <busid> does two things:

    • In PowerShell, it shares the device via usbipd bind -b <busid>
    • In your default WSL instance, it attaches to the shared device via sudo usbip attach -r $(hostname).local -b <busid>. It does this without needing a sudo password because it essentially uses the wsl -u root command.

    For instance, from PowerShell, the following commands should have the same effect as the above convivence version:

    usbipd bind -b <busid>
    wsl -u root -e usbip attach -r "$(hostname.exe).local" -b <busid>
    

    Or you could run the first command in PowerShell, then go into Ubuntu and run:

    sudo usbip attach -r $(hostname).local -b <busid>
    

    All three of these have the same effect.

  • usbipd wsl detach -b <busid> is similar, and does two things:

    • In WSL, usbip detach's the device
    • In PowerShell, usbipd unbind's the device
  • usbipd wsl list really doesn't have an equivalent from inside Ubuntu/WSL2. It is more like usbipd list with the added feature of showing which WSL2 instance has a device attached.

Important Note: It's easy to miss that these are two separate commands, since they are so similar.

  • From PowerShell, the command is usbipd
  • From WSL2, the command is usbip (without the "d")
Troubleshooting

With that in mind, try running some of your commands from within Ubuntu when you have issues.

Try:

sudo usbip port
sudo usbip detach -p 00 # Or whatever the previous command showed

See if that gives you any different message that will help us determine why the:

usbipd wsl attach --busid 2-4

... is giving you an error.

2
  • Hi, I added the messages and the code above in my question post, Thank you
    – DanielePP
    Apr 24, 2022 at 8:48
  • Hey I struggle with a similar issue. sudo usbip port actually stays empty but attaching isn't possible.
    – MaKaNu
    May 20, 2022 at 13:47
1

The error

usbip: error: Attach Request for 2-4 failed - Device busy (exported)

is really related to something on Windows-side using your peripherical.

Run your Task manager on Windows-side, identify which app is using your peripherical, end that task.

Now you'll se it works. In my case, it was the Android adb manager. I ended it and all worked fine.

1
  • If you are connecting an Android device, then it will most likely be ADB Jun 20, 2023 at 7:59
0

Some program can use that port. In my case G-helper uses the port. I closed G-helper and I could attach to wsl2. Look at and close possible program that can use the port

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .