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

--mount support for USB flash drives #6011

Open
HoFamilyMaker opened this issue Oct 1, 2020 · 88 comments
Open

--mount support for USB flash drives #6011

HoFamilyMaker opened this issue Oct 1, 2020 · 88 comments
Assignees
Labels

Comments

@HoFamilyMaker
Copy link

HoFamilyMaker commented Oct 1, 2020

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

image

Originally posted by @HoFamilyMaker in #6008 (comment)

@HoFamilyMaker HoFamilyMaker changed the title mounting a linux disk in WSL 2 after update to 20226 can't moun a linux disk in WSL 2 after update to build 20226 Oct 1, 2020
@HoFamilyMaker HoFamilyMaker changed the title can't moun a linux disk in WSL 2 after update to build 20226 can't mount a linux disk in WSL 2 after update to build 20226 Oct 1, 2020
@OneBlue
Copy link
Collaborator

OneBlue commented Oct 1, 2020

Hi @HoFamilyMaker,
Thanks for reporting this.

This issue has already been identified and will be fixed in an upcoming insider build.

Out of curiosity, what kind of disk are you trying to mount ?

@markwill890
Copy link

Is this related to being able to access a WSL folder of the form...

\wsl$\docker-desktop-data\mnt\wsl\docker-desktop-data\data

with "Attempt to access invalid address" (this has been my Quick Access list in Explorer so I now it WAS the right folder).

Curiously, if I drill down to this folder in Explorer I can see the folder but it is now empty.

I have been using this for months, to edit in VS.Code. As of today, though, that folder is empty and I can no longer access the WordPress plugin I have been developing, since I can't access from VS.Code.

Strangely, though, the web site that is supposedly running from their (localhost) remains available. I'm really confused so any help would be really appreciated.

@HoFamilyMaker
Copy link
Author

HoFamilyMaker commented Oct 1, 2020

Hi @HoFamilyMaker,
Thanks for reporting this.

This issue has already been identified and will be fixed in an upcoming insider build.

Out of curiosity, what kind of disk are you trying to mount ?

Thanks

I found this
https://docs.microsoft.com/en-us/windows/wsl/wsl2-mount-disk

Limitations
USB flash drives are not supported at this time and will fail to attach to WSL 2. USB disks are supported though.

my disk is USB flash
change to USB disks (SSD) run wsl --mount is OK

image

image

@HoFamilyMaker
Copy link
Author

HoFamilyMaker commented Oct 1, 2020

@HoFamilyMaker can you please update to the latest Insider build and try again to see if your problem is resolved?

You'll want to be on preview build 20226 or higher.

Thanks

My windows 10 is latest Insider build 20226
image

I found this

Limitations
USB flash drives are not supported at this time and will fail to attach to WSL 2. USB disks are supported though.

try wsl2 to mount USB flash receive the error 'The remote procedure call failed'
mount extend USB disk is OK

@craigloewen-msft
Copy link
Member

My apologies @HoFamilyMaker I realize that the fix is not yet in Insiders, but thank you for updating! As @OneBlue mentioned we have a fix incoming for this soon, we'll ping this thread when it's available in the latest Insider build.

@therealkenc therealkenc changed the title can't mount a linux disk in WSL 2 after update to build 20226 --mount support for USB flash drives Oct 2, 2020
@Imperatorn
Copy link

Need this so much!

Can't do wsl --mount \.\PhysicalDrive1 :(

@mengesb
Copy link

mengesb commented Nov 26, 2020

I too am affected by this issue. Would really like to manipulate my linux partitions without additional software like Paragon. native support would be excellent.

Guessing this goes for the following as well:

PS C:\Windows\System32> wmic diskdrive list brief
Caption                       DeviceID            Model                         Partitions  Size
INTEL SSDSC2BA400G4           \\.\PHYSICALDRIVE0  INTEL SSDSC2BA400G4           4           400085844480
SanDisk Ultra Fit USB Device  \\.\PHYSICALDRIVE1  SanDisk Ultra Fit USB Device  3           15373048320

PS C:\Windows\System32> wsl --mount \\.\PHYSICALDRIVE1 --bare
The system cannot find the drive specified.
PS C:\Windows\System32> wsl --mount \\.\PHYSICALDRIVE1 --partition 3
The system cannot find the drive specified.

I tried also with my SD card device, but that's definitely flash memory.

@BakedCrossiant
Copy link

Any update?

@craigloewen-msft
Copy link
Member

Hey folks, wanting to add some clarity here since I realize that my last comment was not very clear. We added a fix for the 'remote procedure call failed' which was the immediate blocker for this in the root issue. However WSL --mount does not yet have support for USB flash drives formatted in Linux file formats. If you'd like to mount a flash drive in WSL you can do that if it's seen in Windows (in other words, if it's formatted in a file format that Windows understands like NTFS) using sudo mount -t drvfs f: /mnt/usbDrive if you have a USB flash drive as F: on windows. As of right now we do not have support for USB flash drives formatted in other file formats that Windows can't understand. In the future we'll be investigating adding support for flash drives to wsl --mount as a feature request for future iterations, but this is currently a backlog request.

@kb3mkd
Copy link

kb3mkd commented Apr 8, 2021

The reason I want wsl to work is so I can work on Raspberry pi drives from my Windows PC or laptop.

@Imperatorn
Copy link

I want this so I can dd

@laszewsk
Copy link

laszewsk commented Jun 7, 2021

It would be great to get more clarification on this if It now works or not. I am confused if it works or not.

Use case why we like this feature:

A bunch of us seem to want to get access to the Raspberry PI sdcards so we can manipulate them. Originally we wanted to use wsl2 (the development version but the person working on this failed o get it working). Thus we developed an alternative in for gitbash at https://github.com/cloudmesh/cloudmesh-pi-burn in the branch https://github.com/cloudmesh/cloudmesh-pi-burn/tree/windows
This is so we can in the meanwhile access the boot partition in windows directly.
For this we developed a Diskpart class and it works reasonably well (not everything is yet working. we have not done the write part yet). HOwever if we were to have this in wsl2 we could do something like https://cloudmesh.github.io/pi/tutorial/raspberry-burn/ directly in wsl2.
Right now we use gitbash.

I think many of us using the Pi for education would really appreciate a clarification about the status of this. Thanks

@craigloewen-msft
Copy link
Member

@laszewsk as of right now --mount does not support USB flash drives if they are formatted in a Linux file format. This issue is left open to track this request. Please see this comment for full details: #6011 (comment)

@Bluscream
Copy link

Can someone tell me how to do this please? I need to fsck my raspi card

@laszewsk
Copy link

laszewsk commented Jan 5, 2022

you could do a boot from a live linux CD and then use fsck from that.

In case you like to burn multiple SD Cards for a PI cluster, we updated our documentation at

@Bluscream
Copy link

you could do a boot from a live linux CD and then use fsck from that.

In case you like to burn multiple SD Cards for a PI cluster, we updated our documentation at

Thanks, i've tried that but it was unable to fix my card through Parted and commandline

@blockfeed
Copy link

+1, this feature is critical for anyone doing embedded development (and relies on transfers from SD cards via USB adapter).

@luizoti
Copy link

luizoti commented Apr 3, 2022

Same thing here, when using an sd card with adapter.

+1, this feature is critical for anyone doing embedded development (and relies on transfers from SD cards via USB adapter).

@AlexeiScherbakov
Copy link

Workaround is use Usb Reader (notebook integrated not allways works) + VMWare with Debian and GParted
You can install VMWare Player, becase it now works with WLS2, but without hardware accelleration

@Eugene-Lam
Copy link

Eugene-Lam commented Jun 2, 2022

Same here, not working using USB reader

DeviceID           Caption                          Partitions Size          Model
--------           -------                          ---------- ----          -----
\\.\PHYSICALDRIVE0 Samsung SSD 970 EVO Plus 1TB     3          1000202273280 Samsung SSD 970 EVO Plus 1TB
\\.\PHYSICALDRIVE2 Lexar SD  WorkflowUR2 USB Device 2          15924142080   Lexar SD  WorkflowUR2 USB Device
\\.\PHYSICALDRIVE3 Lexar SD  WorkflowUR2 USB Device 0                        Lexar SD  WorkflowUR2 USB Device
\\.\PHYSICALDRIVE1 Lexar SD  WorkflowUR2 USB Device 0                        Lexar SD  WorkflowUR2 USB Device

PS C:\Users\Eugene> wsl --mount \\.\PHYSICALDRIVE2
The system cannot find the drive specified.

laptop buildin sd card slot not working too

PS C:\Users\Eugene> wmic diskdrive list brief
Caption                       DeviceID            Model                         Partitions  Size
Samsung SSD 970 EVO Plus 1TB  \\.\PHYSICALDRIVE0  Samsung SSD 970 EVO Plus 1TB  3           1000202273280
PciE SDHC-Card                \\.\PHYSICALDRIVE1  PciE SDHC-Card                2           15924142080

PS C:\Users\Eugene> wsl --mount \\.\PHYSICALDRIVE1
The system cannot find the drive specified.

@josh-hetland
Copy link

+1 on the desire to interact with my Pi SD card from windows

@laszewsk
Copy link

laszewsk commented Jun 5, 2022

We just released a new version of cloudmesh-pi-burn: https://cloudmesh.github.io/pi/tutorial/raspberry-burn-windows/
Although we use it for clusters, it can be used to burn a single card. However, the full potential is provided when you burn a cluster directly on the SD Cards, plug them in, switch the pis on and you have a readily configured cluster in your network.
It does not burn in WSL2, BUT it burns on Windows, macOS, and Ubuntu. We use this regularly. Just in case you need a SLURM cluster, we just added documentation on how to do that here https://github.com/cloudmesh/cloudmesh-slurm#readme. We welcome contributions and improvements. We have used this code over the last 2 years and improved upon so it works now with the 64 bit OS.

@akash07k
Copy link

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

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

🤣 True

@Animesh-Thakur
Copy link

Animesh-Thakur commented Mar 27, 2023

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

akash07k commented Mar 27, 2023 via email

@bengalih
Copy link

bengalih commented May 7, 2023

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:

  • Waited well over a year for the following issue to be resolved and "mount" ported from insider builds to the wslstore release:
    --mount option available on Win10 (non-Insider) #7940

  • Now that wsl --mount can be used on Windows 10 natively, I get:
    The system cannot find the drive specified

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

JiaHuann commented Aug 1, 2023

The same here,Looking forward to deal with it early

@MaximumPotato
Copy link

MaximumPotato commented Aug 28, 2023

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

alexeldeib commented Sep 1, 2023

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

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

Cris-- commented Dec 12, 2023

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

keithstellyes commented Dec 16, 2023

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

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

pmunin commented Jan 14, 2024

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

warpdesign commented Jan 24, 2024

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

Feijo commented Feb 6, 2024

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

@cad42s13
Copy link

cad42s13 commented Feb 15, 2024

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

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

@bltcn
Copy link

bltcn commented Mar 15, 2024

me too

@alfred-zaki
Copy link

TheOfficeMichealGIF

@badigit
Copy link

badigit commented Jun 9, 2024

need solution

@dominic-valentino-anode

Come on MS please make this work!

@novitk
Copy link

novitk commented Jun 18, 2024

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

@jaredkrinke
Copy link

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!

@realyukii
Copy link

realyukii commented Jul 14, 2024

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

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

@Nirmal4G
Copy link

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.

@UchihaYuki
Copy link

Need SD Card reader support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests