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 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

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
Copy link

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.

@ghost
Copy link
Author

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?

@sirredbeard
Copy link
Contributor

Generally yes.

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

@ghost
Copy link
Author

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

@ghost
Copy link
Author

ghost commented Apr 30, 2020

Generally yes.

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

Bad news.

@ghost
Copy link
Author

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)

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

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!

@miloshavlicek
Copy link

@sirredbeard Any news about the support in default build?

@mtrojnar
Copy link

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
Copy link

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

@Balderick
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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

@Marietto2008
Copy link

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.

@mtrojnar
Copy link

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

@Marietto2008
Copy link

Marietto2008 commented Jul 2, 2020 via email

@mtrojnar
Copy link

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.

@Marietto2008
Copy link

Marietto2008 commented Jul 2, 2020 via email

@jbdamiano
Copy link

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
Copy link

amfern commented Jul 19, 2020

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

@jbdamiano
Copy link

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

@Marietto2008
Copy link

Marietto2008 commented Jul 20, 2020 via email

@SmartBoy84
Copy link

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

@thiscantbeserious
Copy link

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

@jonashger
Copy link

+1

2 similar comments
@luggi
Copy link

luggi commented May 22, 2021

+1

@fjalvarezdd
Copy link

+1

@noverby
Copy link

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.

@dw-0
Copy link

dw-0 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.

@noverby
Copy link

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.

@ZimmerA
Copy link

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

@mrchrisster
Copy link

+1

@My1
Copy link

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.

@SheepReaper
Copy link

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

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

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.

@Johnsel
Copy link

Johnsel commented May 24, 2021 via email

@SheepReaper
Copy link

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.

@dancronintix
Copy link

Is there any plans for this?

@SheepReaper
Copy link

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.

@atsaloli
Copy link

atsaloli commented Sep 3, 2021

See https://docs.microsoft.com/en-us/windows/wsl/wsl2-mount-disk

@gmos
Copy link

gmos commented Sep 3, 2021 via email

@atsaloli
Copy link

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.

@tejasvi
Copy link

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

@virtualhere
Copy link

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

@fearthecowboy
Copy link
Member

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

@sudip-mondal-2002
Copy link

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

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
Development

No branches or pull requests