microsoft / WSL

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

--mount support for USB flash drives #6011

Open HoFamilyMaker opened 4 years ago

HoFamilyMaker commented 4 years ago

upgrade to build 20226 run this command wsl --mount receive the error 'The remote procedure call failed'

image

Originally posted by @HoFamilyMaker in https://github.com/microsoft/WSL/issues/6008#issuecomment-702081473

ndemarco commented 1 year ago

Two years later, still not fixed.

PS C:\Users\Loong> wsl --mount \\.\PHYSICALDRIVE2 --bare
系统找不到指定的驱动器。
Error code: Wsl/Service/AttachDisk/0x8007000f

It's a feature request. It can't be 'fixed' because it was never broken.

absolutelynothelix commented 1 year ago

@ndemarco, it’s broken because it’s not only about flash drives. i can’t even mount my hdd.

ndemarco commented 1 year ago

@absolutelynothelix this issue relates to mounting USB flash drives, not hdd / ssd.

absolutelynothelix commented 1 year ago

@ndemarco, ~it's just a user assumption that the issue is related to a particular kind of drives. we don't know how it's implemented and we can't say that the issue is in the type of a drive being mounted.~ my bad, read the thread carefully. can't find an issue that covers my problem, so i'll probably create a new one when i'll be on windows.

Imperatorn commented 1 year ago

Is anyone at Microsoft aware of this issue?

sambartle commented 1 year ago

Probably. But clearly they don't care about it.

lanlach commented 1 year ago

Would really like to see this functionality implemented soon

Animesh-Thakur commented 1 year ago

Leaving a comment to get notifications for this, till now, I've tried recompiling the kernel using the guide from this link https://www.youtube.com/watch?v=iyBfQXmyH4o , but this does not work for my internal sd-card reader which shows up as this when usbpid is used and the command usb-devices is run in Ubuntu (or kali) T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 5 Spd=480 MxCh= 0 D: Ver= 2.01 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=0bda ProdID=0177 Rev=77.11 S: Manufacturer=Generic S: Product=USB2.0-CRW S: SerialNumber=20121112761000000 C: #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=(none) E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

akash07k commented 1 year ago

@Animesh-Thakur Nice, so is USB support working now in your WSL distros and kernel?

Leaving a comment to get notifications for this, till now, I've tried recompiling the kernel using the guide from this link https://www.youtube.com/watch?v=iyBfQXmyH4o , but this does not work for my internal sd-card reader which shows up as this when usbpid is used and the command usb-devices is run in Ubuntu (or kali) T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 5 Spd=480 MxCh= 0 D: Ver= 2.01 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=0bda ProdID=0177 Rev=77.11 S: Manufacturer=Generic S: Product=USB2.0-CRW S: SerialNumber=20121112761000000 C: #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=(none) E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms

Animesh-Thakur commented 1 year ago

I had to look around the menuconfig for a bit and set another flag for my internal card reader to work, and yes, it does work, unfortunate it isn't the default behaviour though

dewijones92 commented 1 year ago

I found what worked for me best was to delete windows and install ubuntu

akash07k commented 1 year ago

Great, can you share your kernel so that I can quickly check if it works for me? Later will build it for myself.

I found what worked for me best was to delete windows and install ubuntu

knightian commented 1 year ago

I found what worked for me best was to delete windows and install ubuntu

🤣 True

Animesh-Thakur commented 1 year ago

Great, can you share your kernel so that I can quickly check if it works for me? Later will build it for myself.

I found what worked for me best was to delete windows and install ubuntu

Can't upload kernel to something which I'll feel comfortable sharing, might write my step by step when I have time, but that'll have to wait, hope you can work it out without my help, because I won't count on it.

PS. can't upload it on GH, size too large

akash07k commented 1 year ago

Ok, I'll try this weekend.

If you write your tutorial in between, then let me know.

On 3/27/2023 10:07 PM, Animesh Thakur wrote:

Great, can you share your kernel so that I can quickly check if it
works for me? Later will build it for myself.

    I found what worked for me best was to delete windows and
    install ubuntu

Can't upload kernel to something which I'll feel comfortable sharing, might write my step by step when I have time, but that'll have to wait, hope you can work it out without my help, because I won't count on it.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/WSL/issues/6011#issuecomment-1485463262, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQWBM3EIA5HWH63IG3UZXTW6G64XANCNFSM4SAKTF3Q. You are receiving this because you commented.Message ID: @.***>

bengalih commented 1 year ago

Just wanting to clarify here and maybe help serve as a reminder for anyone else coming to this thread that hasn't read all the way through:

This is because , according to this issue, USB flash drives (which is what I needed to mount all along) are still not supported even after almost 3 years of this issue being open?! (I can't be sure, but it also appears that the built-in mount option also does not support mounting non-windows formatted filesystems???)

Currently, WSL 2 does not support USB devices by default.

However, their support wiki page also states:

Recent versions of Windows running WSL kernel 5.10.60.1 or later already include support for common scenarios like USB-to-serial adapters and flashing embedded development boards. If you're trying to do one of these tasks on Ubuntu, you can avoid recompiling the kernel by following the WSL Setup instructions at the top of this page. If you require special drivers, you'll need to build your own kernel for WSL 2.

I'm still running off the kernel I compiled with no issues, but it seems that some users may not need to compile their own kernels.

In short, it seems that the "wsl --mount" option is still severely lacking in functionality and that usbipd-mount may be the preferable solution.

Is there any advantage, if USB support is now compiled into WSL kernel and therefore usbipd-win setup is very easy to use "wsl --mount" over usbipd-win?

With usbupd-win I was able to perform block-level operations against a mounted USB flash drive. I would think that most other operations would build on top of that and not have issues.

If it were up to me, at this point, I would recommend the use of usbipd-win in any scenario due to my experience and the limitations of "wsl --mount". With the exception of 5 minutes of setup, there seems to me no disadvantage. However I am but one user and admittedly do not understand the full scope of the underlying architecture between the two choices.

Can anyone speak to how/why/when "wsl --mount" would be a superior option?

JiaHuann commented 1 year ago

The same here,Looking forward to deal with it early

MaximumPotato commented 1 year ago

@OneBlue @craigloewen-msft Hey folks, what ever became of this issue? I just plopped the SD card from one of my Rasp Pi's into a card reader and thought I'd be able to access its contents from WSL to move some stuff around. That feels like a pretty basic and common use-case for WSL to me if one does not have some flavor of Linux on hand to access non-NTFS / FAT formatted drives. I'm guessing this is very difficult feature to implement, given how long this ticket has been open?

alexeldeib commented 1 year ago

for what it's worth, I was able to access a luks partition on a USB drive by using usbipd approach. I needed to rebuild my kernel with CONFIG_USB_STORAGE, everything else was already enabled by default. I followed the steps here to rebuild, additionally configuring CONFIG_USB_STORAGE as the steps only mention CONFIG_USB and other basic USB driver configuration.

if that works with devmapper and encrypted partitions, I imagine it would cover most scenarios, which probably also explains the relative low priority/long issue age.

AndrewMcCdB commented 11 months ago

@alexeldeib I also managed this by the method you link to, on Windows 11. However the external SD card reader I wanted to talk to is on a USB-C dock that is also driving my 2 external monitors. I got control of the SD card, but in doing so, I lost the displays. This condition persists after reboot. The PC is no longer able to use the dock to drive the external monitors. So I'll have to roll back to the standard wsl kernel. Using a raspberry pi for this kind of work is still the most sensible answer.

Cris-- commented 9 months ago

Still can't edit SD-Card in a USB-Adapter. Trying it with a LibreElec ext4 partition.

PS C:\Users\Xeno> wsl --mount \\.\PHYSICALDRIVE2 --bare Das System kann das angegebene Laufwerk nicht finden. Error code: Wsl/Service/AttachDisk/0x8007000f

keithstellyes commented 9 months ago

Disappointing this is still an issue. Recommended friend to use WSL to set up an SD card for Arch for Raspberry Pi, since I assumed this would just work, unfortunately just get the same issue as described numerous times in this thread.

+1 for "just install Linux" gang

bpringlemeir commented 9 months ago

for what it's worth, I was able to access a luks partition on a USB drive by using usbipd approach. I needed to rebuild my kernel with CONFIG_USB_STORAGE, everything else was already enabled by default. I followed the steps here to rebuild, additionally configuring CONFIG_USB_STORAGE as the steps only mention CONFIG_USB and other basic USB driver configuration.

Wouldn't it make sense to release the stock builds with CONFIG_USB_STORAGE. Then usbipd.exe would be a method to access a USB stick. This is what I was initially trying, before I heard of the '--mount' option to wsl. Is this is a real overhead in the kernel. At the very least it could be a module supplied with the distro releases. It is clear lots of people desire this feature and MS has probably wasted more time responding to this thread than the time it would take to bundle USB_STORAGE.

I alway just revert to using a Linux box instead trying to use WSL2 for this issue. Compiling custom WSL2 kernels is too much effort.

pmunin commented 8 months ago

It's 2024 and still...

$/ GET-WMIOBJECT -query "SELECT * from Win32_DiskDrive"
....
Partitions : 0
DeviceID   : \\.\PHYSICALDRIVE2
Model      : Mass Storage Device USB Device
Size       : 128042933760
Caption    : Mass Storage Device USB Device

$/ wsl --mount \\.\PHYSICALDRIVE2
The system cannot find the drive specified.
warpdesign commented 8 months ago

Same error here.

PS C:\Windows\system32> GET-CimInstance -query "SELECT * from Win32_DiskDrive"

DeviceID           Caption                    Partitions Size         Model
--------           -------                    ---------- ----         -----
\\.\PHYSICALDRIVE1 SDXC Card                  1          128042933760 SDXC Card
\\.\PHYSICALDRIVE0 SAMSUNG MZFLV256HCHP-000MV 3          256052966400 SAMSUNG MZFLV256HCHP-000MV

PS C:\Windows\system32> wsl --mount \\.\PHYSICALDRIVE1 --bare
Le lecteur spécifié est introuvable.
Error code: Wsl/Service/AttachDisk/HCS/0x8007000f
Feijo commented 8 months ago

It's been 4 years, Microsoft, c'mon...

cad42s13 commented 7 months ago
PS C:\Windows\system32> GET-CimInstance -query "SELECT * from Win32_DiskDrive"

DeviceID           Caption                              Partitions Size          Model
--------           -------                              ---------- ----          -----
\\.\PHYSICALDRIVE0 SAMSUNG MZVL4512HBLU-00BLL           3          512105932800  SAMSUNG MZVL4512HBLU-00BLL
\\.\PHYSICALDRIVE1 NORELSYS 1081CS0 USB Device          0                        NORELSYS 1081CS0 USB Device
\\.\PHYSICALDRIVE4 Microsoft Virtual Disk               1          1099506078720 Microsoft Virtual Disk
\\.\PHYSICALDRIVE2 NORELSYS 1081CS1 USB Device          2          64083156480   NORELSYS 1081CS1 USB Device
\\.\PHYSICALDRIVE3 Kingston UHS-II SD Reader USB Device 0          15924142080   Kingston UHS-II SD Reader USB Device

PS C:\Windows\system32> wsl --mount \\.\PHYSICALDRIVE2 --bare
The system cannot find the drive specified.
Error code: Wsl/Service/AttachDisk/0x8007000f
SteffenSH commented 7 months ago

See also many other issues like #8090 and #8408.

bltcn commented 6 months ago

me too

alfred-zaki commented 5 months ago

TheOfficeMichealGIF

badigit commented 3 months ago

need solution

dominic-valentino-anode commented 3 months ago

Come on MS please make this work!

novitk commented 3 months ago

Another 6 month go by. Why is this so hard to implement, MS?

jaredkrinke commented 3 months ago

In case anyone else also only needs to read files from a Linux-formatted microSD card, I will share a Hyper-V-based workaround (which, again, only works for reading; it does not work for writing).

Rather than installing third-party software and opening up a port to my local subnet (!), I was able to inconveniently work around the lack of built-in USB drivers (in WSL 2.2.4.0, kernel 5.15.153.1-2) using Hyper-V by:

  1. Cloning the microSD card into a VHD file using Hyper-V -> Action ->New -> Hard Disk -> ... -> Configure Disk -> Copy the contents of the specified physical disk
  2. Mounting the VHD via wsl --mount <path to VHD> --vhd
  3. Mounting the relevant partition (in my case, /dev/sdd2) from within WSL

Note that this copies the whole drive, so it's quite slow--but still faster than figuring out how to recompile the WSL2 kernel to add the usb-storage module--at least for me!

RealYukiSan commented 2 months ago

I followed this guide but got the same error as others.

EDIT: NVM, I just forgot to specify the partition that I want to mount to.

KuzuryuYaichi commented 2 months ago

As this isuue is so utility for embedded developers, could MS work harder on it?

Nirmal4G commented 1 week ago

I hit this too. May be not related to embedded development, but I have a secondary 512GB Flash drive and SSD 2230 disk, and I would very much like to move all my WSL distros to disk instead of using VHDs on Windows System disk. I'm also trying to see if I can merge both desktop and WSL editions into one partition so that I can use the same image for Azure, Hyper-V, Bare metal boot and WSL scenarios.