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

SD Card Mounting in WSL2 from Win 11 and a USB Card Reader #8408

Closed
silver2row opened this issue May 13, 2022 · 23 comments
Closed

SD Card Mounting in WSL2 from Win 11 and a USB Card Reader #8408

silver2row opened this issue May 13, 2022 · 23 comments

Comments

@silver2row
Copy link

hello, zouherenjie Same problem happens when I am trying to mount the ext4.vhdx image of my previous WSL. Would you please tell me how to manually mount the disk? I have really tried to find some way to deal with it. But none of them effective. Sorry for my poor English :)

@huiyeruzhou , unfortunately, my disk disappeared after one failed boot of WSL2. I hope my experience can help you.

  1. delete all partitions of the disk you want to mount

  2. mount the disk barely in powershell wsl --mount <DiskPath> --bare

  3. find you disk in WSL2 by blkid or lsblk or fdisk -l
    image

  4. build a new partition with ext4 filesystem in WSL2
    mkfs.ext4 /dev/sdf1

  5. unmount the disk wsl --unmount <DiskPath>

  6. mount the disk barely again in powershell wsl --mount <DiskPath> --bare
    Now you should see the disk with ext4 filesystem by blkid

image

  1. Finally you can mount the disk manually in WSL2 such as mount /dev/sdf /app

Originally posted by @zouherenjie in #8215 (comment)

Hello,

I am having issues connecting to a SD Card, mounting it, and using WSL2.

I tried diskpart, wsl, and other commands. I cannot mount the SD Card to turn it into an ext4 partition so I can mount it to put data on it.

Seth

@silver2row
Copy link
Author

I have found that there are issues with USB Ports on WSL2 instances from a Win 11 dev. desktop. Are there any workarounds or destination tutorials for this effort?

I am asking b/c I found usbipd but that has not worked so far.

Seth

@silver2row
Copy link
Author

So...

I can make usbipd work but it does not allow me to access the USB Card Reader and the SD Card in the Card Reader.

Is this a limitation on WSL2 or is it a usbipd concern?

Seth

P.S. Is there any method to look into for finding out why the Card Reader and SD Card are not allowing me to access the SD Card?

@OneBlue
Copy link
Collaborator

OneBlue commented May 17, 2022

Thanks for reporting this @silver2row.

Can you share the exact commands you run, and what the output is ? What do you mean exactly by 'does not allow me to access the USB Card Reader' ?

@silver2row
Copy link
Author

silver2row commented May 17, 2022

@OneBlue ,

Hello...sure. I will attempt to reproduce the commands but w/out notes on what actually took place, I am in the dark myself.

Oh...

By, does not allow me to access the USB Card Reader, I basically mean that it says it is there in Windows but in WSL2 on Windows, I cannot access the /media/$USER/My Card Reader port.

And...

I just figured this would have been a big deal. I read over how to manage specifics on other channels online for the usbipd lib. and found the page(s) not too telling.

Seth

P.S. I will try to reproduce the commands in diskpart and WSL2 and then reply once more. I will be more constructive and soon. Thank you for replying.

@ghost ghost removed the needs-author-feedback label May 17, 2022
@silver2row
Copy link
Author

silver2row commented May 21, 2022

in Terminal as an administrator user

  1. GET-CimInstance -query "SELECT * from Win32_DiskDrive"
  2. wsl --mount \.\PHYSICALDRIVE2 --bare
    The system cannot find the drive specified.
  3. usbipd wsl list
    a. This command shows the wsl instance of my USB as:
BUSID  VID:PID    DEVICE                                                        STATE
1-5    17ef:60a9  USB Input Device                                              Not attached
1-10   8087:0aaa  Intel(R) Wireless Bluetooth(R)                                Not attached
1-13   05dc:b050  USB Mass Storage Device                                       Not attached
  1. usbipd wsl attach --busid 1-13
  2. The usbipd wsl attach --busid 1-13 command works and now I can see my devices in WSL2 on Debian.

in wsl2

  1. lsusb

Bus 002 Device 002: ID 05dc:b050 Lexar Media, Inc. USB_3_0 Reader

  1. But when I go to /media/ on Debian, I do not see my mounted SD Card in the USB_3_0 Reader.

@silver2row
Copy link
Author

Hello Again,

I checked /media/ and /mnt/ but it is not listed anywhere I look. I checked /dev/ too.

Seth

P.S. I am still not able to read my SD Card contents from w/in WSL2 which is running Debian.

@OneBlue
Copy link
Collaborator

OneBlue commented May 26, 2022

Thanks for the info @silver2row. Can you share the output of dmesg after you attach the USB card reader to wsl ?

@silver2row
Copy link
Author

silver2row commented May 30, 2022

Sure.

I will get on it soon. Thank you for replying so quickly.

Seth

P.S. I am going to take a shot in the dark here. I think since I cannot update to the latest linux-headers-$(uname -r), I am stuck for now. The show must go on! brb

@ghost ghost removed the needs-author-feedback label May 30, 2022
@silver2row
Copy link
Author

Okay and Sorry Here,

I am here. So,

without usbipd being attached to the USB Card Reader with a SD Card in it


[    2.399986] pci 1aaf:00:00.0: reg 0x18: [mem 0x9ffe0d000-0x9ffe0dfff 64bit]
[    2.400940] pci 1aaf:00:00.0: reg 0x20: [mem 0x9ffe0e000-0x9ffe0efff 64bit]
[    2.404559] pci 1aaf:00:00.0: BAR 0: assigned [mem 0x9ffe0c000-0x9ffe0cfff 64bit]
[    2.405591] pci 1aaf:00:00.0: BAR 2: assigned [mem 0x9ffe0d000-0x9ffe0dfff 64bit]
[    2.406537] pci 1aaf:00:00.0: BAR 4: assigned [mem 0x9ffe0e000-0x9ffe0efff 64bit]
[    2.535495] hv_pci ed2665c1-7f50-4682-8e53-08c9c13ec0f0: PCI VMBus probing: Using version 0x10003
[    2.536948] 9pnet_virtio: no channels available for device drvfs
[    2.537479] init: (1) WARNING: mount: waiting for virtio device...
[    2.604328] hv_pci ed2665c1-7f50-4682-8e53-08c9c13ec0f0: PCI host bridge to bus 7f50:00
[    2.604966] pci_bus 7f50:00: root bus resource [mem 0xbffe10000-0xbffe12fff window]
[    2.606837] pci 7f50:00:00.0: [1af4:1049] type 00 class 0x010000
[    2.608514] pci 7f50:00:00.0: reg 0x10: [mem 0xbffe10000-0xbffe10fff 64bit]
[    2.609690] pci 7f50:00:00.0: reg 0x18: [mem 0xbffe11000-0xbffe11fff 64bit]
[    2.610716] pci 7f50:00:00.0: reg 0x20: [mem 0xbffe12000-0xbffe12fff 64bit]
[    2.615529] pci 7f50:00:00.0: BAR 0: assigned [mem 0xbffe10000-0xbffe10fff 64bit]
[    2.616959] pci 7f50:00:00.0: BAR 2: assigned [mem 0xbffe11000-0xbffe11fff 64bit]
[    2.617899] pci 7f50:00:00.0: BAR 4: assigned [mem 0xbffe12000-0xbffe12fff 64bit]
[    2.660399] hv_pci ea4e564a-0426-4fa2-abdf-c742d3fa0e87: PCI VMBus probing: Using version 0x10003
[    2.725761] hv_pci ea4e564a-0426-4fa2-abdf-c742d3fa0e87: PCI host bridge to bus 0426:00
[    2.726362] pci_bus 0426:00: root bus resource [mem 0xbffe14000-0xbffe16fff window]
[    2.728139] pci 0426:00:00.0: [1af4:1049] type 00 class 0x010000
[    2.729658] pci 0426:00:00.0: reg 0x10: [mem 0xbffe14000-0xbffe14fff 64bit]
[    2.730840] pci 0426:00:00.0: reg 0x18: [mem 0xbffe15000-0xbffe15fff 64bit]
[    2.732069] pci 0426:00:00.0: reg 0x20: [mem 0xbffe16000-0xbffe16fff 64bit]
[    2.736444] pci 0426:00:00.0: BAR 0: assigned [mem 0xbffe14000-0xbffe14fff 64bit]
[    2.737530] pci 0426:00:00.0: BAR 2: assigned [mem 0xbffe15000-0xbffe15fff 64bit]
[    2.738784] pci 0426:00:00.0: BAR 4: assigned [mem 0xbffe16000-0xbffe16fff 64bit]
[   49.769552] hv_balloon: Max. dynamic memory size: 4028 MB
[339437.384680] TCP: eth0: Driver has suspect GRO implementation, TCP performance may be compromised.

and...

with usbipd attached to the USB Card Reader with the SD Card installed in it


[386451.180693] vhci_hcd vhci_hcd.0: pdev(0) rhport(0) sockfd(3)
[386451.182330] vhci_hcd vhci_hcd.0: devid(65549) speed(5) speed_str(super-speed)
[386451.183193] vhci_hcd vhci_hcd.0: Device attached
[386451.525674] usb 2-1: SetAddress Request (2) to port 0
[386451.526682] usb 2-1: new SuperSpeed Gen 1 USB device number 2 using vhci_hcd
[386451.584198] usb 2-1: New USB device found, idVendor=05dc, idProduct=b050, bcdDevice= 0.01
[386451.585167] usb 2-1: New USB device strings: Mfr=3, Product=4, SerialNumber=5
[386451.585829] usb 2-1: Product: USB_3_0 Reader
[386451.586171] usb 2-1: Manufacturer: Lexar
[386451.586347] usb 2-1: SerialNumber: 000000018486

Seth

P.S. I performed dmesg | less only and spaced to the last couple of lines as listed above. I hope this helps. If not, I can give out the entire file(s) from dmesg.

@alexjmoore
Copy link

The issue is lack of usb-storage drivers in the WSL kernel. If they could be added it would be great.

Working but painful workaround (i.e. recompile your own kernel) can be found here: https://www.youtube.com/watch?v=iyBfQXmyH4o

@silver2row
Copy link
Author

Hello,

Thank you for your update. I will try it.

Seth

@silver2row
Copy link
Author

Hello @alexjmoore ,

I am sorry. I followed the instructions from that fellow online. When using lsusb, as usual, the Card Reader shows up. But when using lsblk, I get no partitions. I have a vFat 32 filesystem in a boot partition and a Linux based kernel in my rootfs partition on the SD Card, i.e. two separate partitions.

Seth

P.S. Something funny here though! When I do not use usbipd, I am seeing these partitions mount on my Win 11 machine in the filesystem viewer. Hmm.

@yuhcaesar
Copy link

Hello @alexjmoore ,

I am sorry. I followed the instructions from that fellow online. When using lsusb, as usual, the Card Reader shows up. But when using lsblk, I get no partitions. I have a vFat 32 filesystem in a boot partition and a Linux based kernel in my rootfs partition on the SD Card, i.e. two separate partitions.

Seth

P.S. Something funny here though! When I do not use usbipd, I am seeing these partitions mount on my Win 11 machine in the filesystem viewer. Hmm.

Same issue here, any update?

@spectrapulse
Copy link

Not sure why this is closed. But maybe it would be useful to actually document a way to connect an SDCard to WSL. It would be useful for exploring the SDCards on small singleboard computers such as a raspberrypi.

@yanorei32
Copy link

yanorei32 commented Aug 14, 2022

@spectrapulse I think, it is resolved here. #7770

@spectrapulse
Copy link

@spectrapulse I think, it is resolved here. #7770

a workaround is not a solution

@chrisdpratt
Copy link

@spectrapulse I think, it is resolved here. #7770

a workaround is not a solution

Agreed. I just hit this wall myself. If you can resolve it by rebuilding the kernel to add USB support, then why in the world doesn't Micrsoft just ship a kernel with USB support in the first place? What's the rationale for specifically removing support for USB?

@MrDaGree
Copy link

I'm confused why this got closed - I would love to be able to mount USB flash drives/SD cards into WSL but would prefer not needing to rely on building my own kernel

@widget-
Copy link

widget- commented Oct 14, 2022

I'm able to mount it with sudo mount -t drvfs 'E:' /mnt/e

I don't think you'll be able to format it as ext4 with that though.

@dreaddymck
Copy link

dreaddymck commented Sep 9, 2023

I'm able to mount it with sudo mount -t drvfs 'E:' /mnt/e

I don't think you'll be able to format it as ext4 with that though.

This works for me, thank you.

@sprsr
Copy link

sprsr commented Jan 17, 2024

I'm able to mount it with sudo mount -t drvfs 'E:' /mnt/e

I don't think you'll be able to format it as ext4 with that though.

This solution did not work for me. Curious what version of WSL someone who has successfully used it on is running, and what distribution.

@Miunmn
Copy link

Miunmn commented Jun 11, 2024

Hello~~
I don't know if this is the best way but I made it work

  1. Compile WSL2 Kernel to support USB and MMC (also during the guided menu of the Kernel Compilation I added support to multiple devices)
  2. Run WSL2 with new Kernel using .wslconfig file
  3. Connecting USB devices to WSL2 More info here
  4. Mount USB data in WSL2. Now I can W/R USB data

I'd love some support from Microsoft...

@mikegoatly
Copy link

For others who end up here, I found this useful: https://www.tomshardware.com/how-to/access-linux-ext4-partitions-in-windows

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