microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.44k stars 822 forks source link

[WSL 2] Attaching an USB device #5158

Closed ghost closed 4 years ago

ghost commented 4 years ago

I want to attach an USB device (iPhone) with WSL, how to accomplish that? USB device is connected with Windows host. I'm using kernel 4.19.104 and enabled USB support manually by compiling it from source.

Any suggestions regarding above mentioned issues?

sirredbeard commented 4 years ago

WSL 2 operates in a lightweight VM and does not have USB pass-through access.

Even if enabled in the Linux kernel, that is still simply inside the VM.

This is a duplicate of #689.

Biswa96 commented 4 years ago

Even if enabled in the Linux kernel, that is still simply inside the VM.

Nope, it "was" somehow possible. See this pull request https://github.com/microsoft/WSL2-Linux-Kernel/pull/45. I tried it once but the compiled kernel did not boot WSL2 VM, maybe I did something wrong.

ghost commented 4 years ago

WSL 2 operates in a lightweight VM and does not have USB pass-through access.

Even if enabled in the Linux kernel, that is still simply inside the VM.

This is a duplicate of #689.

@sirredbeard so for now there’s no way to attach USB devices into WSL?

sirredbeard commented 4 years ago

Generally yes.

There are hacks that use USB over IP but they aren't supported and YMMV.

ghost commented 4 years ago

Even if enabled in the Linux kernel, that is still simply inside the VM.

Nope, it "was" somehow possible. See this pull request microsoft/WSL2-Linux-Kernel#45. I tried it once but the compiled kernel did not boot WSL2 VM, maybe I did something wrong.

Also tried by me. But usbip can’t attach usb devices with WSL. I’m already having a long discussion here- https://github.com/cezanne/usbip-win/issues/149

ghost commented 4 years ago

Generally yes.

There are hacks that use USB over IP but they aren't supported and YMMV.

Bad news.

ghost commented 4 years ago

My issue is solved with USB/IP tool from this repo: https://github.com/cezanne/usbip-win I have compiled kernel 4.19.104 with USB modules and now I can attach USB devices with WSL using USB/IP. My solution goes like this: https://github.com/cezanne/usbip-win/issues/149#issuecomment-622367314

Marietto2008 commented 4 years ago

I tried to attach the kinect,using usbip and this is what happened :

root@DESKTOP-N9UN2H3:~/Desktop# sudo ./libfreenect2/build/bin/Protonect Version: 0.2.0 Environment variables: LOGFILE= Usage: ./libfreenect2/build/bin/Protonect [-gpu=] [gl | cl | clkde | cuda | cudakde | cpu] [] [-noviewer] [-norgb | -nodepth] [-help] [-version] [-frames ] To pause and unpause: pkill -USR1 Protonect [Info] [Freenect2Impl] enumerating devices... [Info] [Freenect2Impl] 2 usb devices connected [Info] [Freenect2Impl] found 0 devices no device connected!

miloshavlicek commented 4 years ago

@sirredbeard Any news about the support in default build?

mtrojnar commented 4 years ago

My issue is solved with USB/IP tool from this repo: https://github.com/cezanne/usbip-win I have compiled kernel 4.19.104 [...]

I'm glad it worked for you, but I personally do not think that USB support in WSL2 should require recompiling a custom Linux kernel and installing a prerelease of a Windows kernel driver. This feature should just work out of the box.

chris1000 commented 4 years ago

I wanted to follow up with this and see if there has been any news of this feature coming by default?

Balderick commented 4 years ago

After getting Steam for Linux installed in Ubuntu On Windows, i am interested in this feature request or limitation of WSL2 as well.

Could not help thinking of VirtualHere but have only used android server with non linux clients (mostly remote cloud gaming VMs like Paperspace and Shadow running windows or windows server) and can see VirtualHere has CLI for linux clients at https://www.virtualhere.com/node/955.

Yeah YMMV but am sure a custom kernel and VH can help out for many end user case scenarios in WSL.

jbdamiano commented 4 years ago

The issue is not resolved by usbip because when you install the windows part you have to remove protection, test signature. This could be an attack vector on your machine and could not be accepted on work computer, So we need to have some internal tools to be able to do that. If USB-IP is working correctly why we don't have it available directly by Windows when se enable some additional tools ?

mtrojnar commented 4 years ago

The issue is not resolved by usbip

Well, it would be addressed by USB/IP if USB/IP kernel code was merged into the Microsoft's WSL2 kernel. But you are right, this issue is not fixed and it should not be closed.

jbdamiano commented 4 years ago

Not only the USP/IP kernel code, wee need to have the USP/IP Windows driver available and signed by microsoft to avoid to do: bcdedit.exe /set TESTSIGNING ON because this in not safe as you have to disable the UEFI secure boot to do that.

Marietto2008 commented 4 years ago

the problem is deeper,since actually on WSL2 there is no official passthrough for the multimedias USB devices.

Marietto2008 commented 4 years ago

But the problem can be fixed with this solution :

onomatopellan commented on 6 May

I found it very easy to use. It's free if you connect 1 device and you use the gui linux version as client.

For the server, just download and run it: https://www.virtualhere.com/sites/default/files/usbserver/vhusbdwin64.exe

For the client (you need an XServer and gtk2):

wget https://www.virtualhere.com/sites/default/files/usbclient/vhuit64 chmod 777 vhuit64 sudo ./vhuit64

After that you can right click -> "Specify the hub" and add YOUR_PC_IP:7575 right click on a device -> Use this device

And that's it. You should see the device with lsusb.

mtrojnar commented 4 years ago

wget https://www.virtualhere.com/sites/default/files/usbclient/vhuit64 chmod 777 vhuit64 sudo ./vhuit64

modprobe: FATAL: Module vhci-hcd not found in directory /lib/modules/4.19.104-microsoft-standard

Marietto2008 commented 4 years ago

you should recompile the kernel and u should activate a lot of parameters related to usb. its better if u don't choose to load as modules.but built into the kernel.

mtrojnar commented 4 years ago

you should recompile the kernel and u should activate a lot of parameters related to usb. its better if u don't choose to load as modules.but built into the kernel.

Rebuilding the WSL2 kernel from sources may work, but functionality as basic as USB support should not require it.

Marietto2008 commented 4 years ago

it seems that it is required. but I think that depends about the wsl-config file that's used.

jbdamiano commented 4 years ago

The issue is not closed. The title is Attaching an USB device. I'm trying to attach an USB modem and it is not working, It is not supported by VirtualHere so it is not the solution for all USB device.

amfern commented 4 years ago

yes this is not closed and its the most important feature for me

jbdamiano commented 4 years ago

For me too. I can't replace my vm with wsl2.

Marietto2008 commented 4 years ago

you can try this : https://www.flexihub.com/download.html

jbdamiano commented 4 years ago

That is not a solution my vm is free. USB sharing was available in WSL1 and not in WSL2.

gmos commented 4 years ago

The absence of USB support makes WSL2 currently unusable for IoT development. Almost all target devices need to connect via USB, mostly USB serial or as a USB flash memory. I would recommend to up the priority of USB support on your feature list. Implementing this (temporarily) via USB over IP would be just fine. But this would need the Linux driver to be pre-compiled into the kernel, either static-linked or as a loadable module being part of the distribution. Likewise for a signed driver at the Windows end.

jbdamiano commented 4 years ago

The absence of USB support makes WSL2 currently unusable for IoT development. Almost all target devices need to connect via USB, mostly USB serial or as a USB flash memory. I would recommend to up the priority of USB support on your feature list. Implementing this (temporarily) via USB over IP would be just fine. But this would need the Linux driver to be pre-compiled into the kernel, either static-linked or as a loadable module being part of the distribution. Likewise for a signed driver at the Windows end.

Totally agree. +1

jesusmogollon commented 4 years ago

+1

mecworks commented 4 years ago

+1

This is required.

nobodyguy commented 4 years ago

+1

ghost commented 4 years ago

Why are you closing the issue? Without USB support WSL is useless for a majority of potential users.

mtrojnar commented 4 years ago

Why are you closing the issue? Without USB support WSL is useless for a majority of potential users.

The issue was closed by a deleted user. There is no point in arguing with her I'm afraid...

Marietto2008 commented 4 years ago

reopen this thread. I'm going to try an experiment and I will post here the result.

xiongyu0523 commented 4 years ago

+1

pabo commented 4 years ago

+1

GreedyA1 commented 4 years ago

+1

nicewarmcoffee commented 4 years ago

+1 came to figure out how to run dd on a usb stick; oh well

impala454 commented 4 years ago

+1

segin commented 4 years ago

WSL 2 operates in a lightweight VM and does not have USB pass-through access.

Even if enabled in the Linux kernel, that is still simply inside the VM.

This is a duplicate of #689.

Not a duplicate, you misunderstand the issue entirely.

689 is about block devices, this is not.

jaytaph commented 4 years ago

+1

gaia commented 4 years ago

+1

marcin-jedynski commented 4 years ago

+ 1

My1 commented 4 years ago

I would totally love to see this too.

ngmariusz commented 4 years ago

reopen

ss2007wow commented 4 years ago

I would also love to know how to make this possible, have an iot device that I need access to the WSL2 and do not have access to a dedicated Linux machine to complete the work, nor the space for a full VM on my current device.

mamoorkhan commented 4 years ago

why was this issue closed?

impala454 commented 4 years ago

Looks like it was mentioned in that PR above and probably automatically closed. Definitely needs to remain open.

mamoorkhan commented 4 years ago

Looks like it was mentioned in that PR above and probably automatically closed. Definitely needs to remain open.

@impala454 It was closed by the OP, because they got their problem solved using USBIP, so I created a new issue #6210 to keep track of this.

MostHated commented 3 years ago

Would like to see this addressed.