Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WSL 2] Attaching an USB device #5158

Closed
ghost opened this issue Apr 30, 2020 · 114 comments
Closed

[WSL 2] Attaching an USB device #5158

ghost opened this issue Apr 30, 2020 · 114 comments

Comments

@ghost
Copy link

@ghost ghost commented Apr 30, 2020

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?

@ghost ghost changed the title WSL 2 attaching an USB device [WSL 2] Attaching an USB device Apr 30, 2020
@sirredbeard
Copy link
Contributor

@sirredbeard sirredbeard commented Apr 30, 2020

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.

Loading

@Biswa96
Copy link

@Biswa96 Biswa96 commented Apr 30, 2020

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.

Loading

@ghost
Copy link
Author

@ghost ghost commented Apr 30, 2020

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?

Loading

@sirredbeard
Copy link
Contributor

@sirredbeard sirredbeard commented Apr 30, 2020

Generally yes.

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

Loading

@ghost
Copy link
Author

@ghost ghost commented Apr 30, 2020

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- cezanne/usbip-win#149

Loading

@ghost
Copy link
Author

@ghost ghost commented Apr 30, 2020

Generally yes.

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

Bad news.

Loading

@ghost
Copy link
Author

@ghost ghost commented May 1, 2020

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: cezanne/usbip-win#149 (comment)

Loading

@ghost ghost closed this May 1, 2020
@Marietto2008
Copy link

@Marietto2008 Marietto2008 commented May 3, 2020

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=<protonect.log>
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!

Loading

@miloshavlicek
Copy link

@miloshavlicek miloshavlicek commented Jun 7, 2020

@sirredbeard Any news about the support in default build?

Loading

@mtrojnar
Copy link

@mtrojnar mtrojnar commented Jun 11, 2020

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.

Loading

@chris1000
Copy link

@chris1000 chris1000 commented Jun 28, 2020

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

Loading

@Balderick
Copy link

@Balderick Balderick commented Jun 28, 2020

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.

Loading

@jbdamiano
Copy link

@jbdamiano jbdamiano commented Jun 30, 2020

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 ?

Loading

@mtrojnar
Copy link

@mtrojnar mtrojnar commented Jun 30, 2020

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.

Loading

@jbdamiano
Copy link

@jbdamiano jbdamiano commented Jun 30, 2020

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.

Loading

@Marietto2008
Copy link

@Marietto2008 Marietto2008 commented Jun 30, 2020

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

Loading

@Marietto2008
Copy link

@Marietto2008 Marietto2008 commented Jun 30, 2020

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.

Loading

@mtrojnar
Copy link

@mtrojnar mtrojnar commented Jul 2, 2020

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

Loading

@Marietto2008
Copy link

@Marietto2008 Marietto2008 commented Jul 2, 2020

Loading

@mtrojnar
Copy link

@mtrojnar mtrojnar commented Jul 2, 2020

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.

Loading

@Marietto2008
Copy link

@Marietto2008 Marietto2008 commented Jul 2, 2020

Loading

@jbdamiano
Copy link

@jbdamiano jbdamiano commented Jul 17, 2020

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.

Loading

@amfern
Copy link

@amfern amfern commented Jul 19, 2020

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

Loading

@jbdamiano
Copy link

@jbdamiano jbdamiano commented Jul 20, 2020

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

Loading

@Marietto2008
Copy link

@Marietto2008 Marietto2008 commented Jul 20, 2020

Loading

@SmartBoy84
Copy link

@SmartBoy84 SmartBoy84 commented May 14, 2021

Why was this closed??? I don't understand why Microsoft has prioritized running a linux DE concurrent with window's over this basic feature??

Loading

@thiscantbeserious
Copy link

@thiscantbeserious thiscantbeserious commented May 16, 2021

+1 not having USB-Passtrough is really a dealbreaker.

Loading

@jonashger
Copy link

@jonashger jonashger commented May 21, 2021

+1

Loading

2 similar comments
@luggi
Copy link

@luggi luggi commented May 22, 2021

+1

Loading

@fjalvarezdd
Copy link

@fjalvarezdd fjalvarezdd commented May 23, 2021

+1

Loading

@noverby
Copy link

@noverby noverby commented May 23, 2021

@Wolf1098 @Rhodderz @MuZhou233 @bossbeagle1509 @mrchrisster @Gallium70 @JaccoVeldscholten @fulcrumEFX @bogdant @ZimmerA @lexxxel @leofabri @v-bortsov @Johnsel @Olegvarmy @eugenov @lucascoelhof @MomoRazor @flasher297 @th33xitus @thiscantbeserious @jonashger @luggi @fjalvarezdd
Would you kindly stop making 'upvote' comments?
All subscribers to this issue get a notification for each of your comments.
Please upvote the issue instead, if you want to show your support.

Loading

@th33xitus
Copy link

@th33xitus th33xitus commented May 23, 2021

@noverby This is your first comment on this topic if i see that correctly. So you weren't even affected by those notifications up until now with your comment. Why do you even feel annoyed? You don't even seem to be involved in this repository (correct me if i am wrong). Probably the amount of comments a topic gets can be a good metric too (activity in a topic = possible demand). Anyone who feels annoyed can just unsubscribe and just keep a bookmark to this topic.

Back to topic:
+1

EDIT:

I'm affected since I'm subscribed. (You don't have to comment to be subscribed)

With every day, you learn something new :) i wasn't aware. Thanks for the hint.

Loading

@noverby
Copy link

@noverby noverby commented May 23, 2021

@th33xitus I'm affected since I'm subscribed. (You don't have to comment to be subscribed)
I subscribe to many issues (not just this issue), where I want to know about actual updates and useful discussions.
I don't see how making upvote comments is a better metric for demand than just upvoting the issue.
A bookmark does not provide notifications about real and useful issue updates.

Please consider my plea. I'm stopping this off-topic discussion now.

Loading

@ZimmerA
Copy link

@ZimmerA ZimmerA commented May 23, 2021

@Wolf1098 @Rhodderz @MuZhou233 @bossbeagle1509 @mrchrisster @Gallium70 @JaccoVeldscholten @fulcrumEFX @bogdant @ZimmerA @lexxxel @leofabri @v-bortsov @Johnsel @Olegvarmy @eugenov @lucascoelhof @MomoRazor @flasher297 @th33xitus @thiscantbeserious @jonashger @luggi @fjalvarezdd
Would you kindly stop making 'upvote' comments?
All subscribers to this issue get a notification for each of your comments.
Please upvote the issue instead, if you want to show your support.

+1

Loading

@mrchrisster
Copy link

@mrchrisster mrchrisster commented May 23, 2021

+1

Loading

@My1
Copy link

@My1 My1 commented May 23, 2021

honestly github might need a spam filter, if everyone properly +1'd the issue via reaction this can be used as a better sorting filter than comment count also and most notably because everyone can only give one reaction.
and this is frankly annoying.

rather than just writing +1 try something productive in the comment, e.g. writing for what you want to use it, or if you can (sure I cannot but maybe some can) try writing on how to go with this.

for example I would love to use this as I have sometimes dockers as build VMs for firmware of stuff and it's a lot easier being able to just flash in the docker rather rather than using whatever crazy methods available to get the firmware out (which is in my case a curl to a specially prepared PHP script) just to flash from the host. having USB in the WSL VMs would be making that whole process a lot easier.

Loading

@SheepReaper
Copy link

@SheepReaper SheepReaper commented May 24, 2021

Chill, it's just baiting to let them lock the conversation to contributors. You should open new issues instead, referencing this one.

Loading

@SheepReaper SheepReaper mentioned this issue May 24, 2021
2 tasks
@lexxxel
Copy link

@lexxxel lexxxel commented May 24, 2021

@Wolf1098 @Rhodderz @MuZhou233 @bossbeagle1509 @mrchrisster @Gallium70 @JaccoVeldscholten @fulcrumEFX @bogdant @ZimmerA @lexxxel @leofabri @v-bortsov @Johnsel @Olegvarmy @eugenov @lucascoelhof @MomoRazor @flasher297 @th33xitus @thiscantbeserious @jonashger @luggi @fjalvarezdd
Would you kindly stop making 'upvote' comments?
All subscribers to this issue get a notification for each of your comments.
Please upvote the issue instead, if you want to show your support.

I understand your request. I commented because this issue has been closed multiple times. Upvotes did not give enough attention to this issue, but email notification do 'push' attention. I hope you can understand that.

Loading

@Johnsel
Copy link

@Johnsel Johnsel commented May 24, 2021

Loading

@SheepReaper
Copy link

@SheepReaper SheepReaper commented May 25, 2021

Well, It seems that my new issue was closed in favor of #2195
At least that answers the question of where they are aggregating these issues. They seem to believe it's all to do with USB pass-through. Though M$ has not commented on an ETA. I guess we can all stop following this one and follow the other instead.

Loading

@dancronintix
Copy link

@dancronintix dancronintix commented Jul 17, 2021

Is there any plans for this?

Loading

@SheepReaper
Copy link

@SheepReaper SheepReaper commented Jul 17, 2021

Is there any plans for this?

This issue is closed and will be ignored. Please follow #2195 instead, for updates, and make sure to upvote the OP in that thread as well.

Loading

@atsaloli
Copy link

@atsaloli atsaloli commented Sep 3, 2021

Loading

@gmos
Copy link

@gmos gmos commented Sep 3, 2021

Loading

@atsaloli
Copy link

@atsaloli atsaloli commented Sep 4, 2021

@gmos Right. To be honest, I stopped reading the vendor documentation when I saw the functionality to mount USB drives was only supported in Windows 11 Preview. I don't have that. I was trying to mount a USB flash drive, so it wouldn't have worked for me anyway.

I'm glad Microsoft is working on improving USB support for WSL though.

Cheers, and thanks for the correction.

Loading

@tejasvi
Copy link

@tejasvi tejasvi commented Sep 24, 2021

TLDR to mount D drive on /mnt/d_folder

sudo mkdir /mnt/d_folder
sudo mount -t drvfs D: /mnt/d_folder

Loading

@virtualhere
Copy link

@virtualhere virtualhere commented Oct 14, 2021

Im getting people asking if virtualhere can pass through usb into wsl2. The answer is now yes with the latest wsl2 kernel

https://www.virtualhere.com/comment/9758#comment-9758

Loading

@fearthecowboy
Copy link
Member

@fearthecowboy fearthecowboy commented Nov 4, 2021

For those who found their way here: https://devblogs.microsoft.com/commandline/connecting-usb-devices-to-wsl/

Loading

@sudip-mondal-2002
Copy link

@sudip-mondal-2002 sudip-mondal-2002 commented Nov 18, 2021

image
I have attached my webcam to wsl2, still cheese shows no device found

Loading

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet