microsoft / WSL

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

External drive --mount in WSL2 yields "The system cannot find the file specified." #6910

Closed maxboone closed 1 year ago

maxboone commented 3 years ago

Windows Build Number

10.0.21370.1 (ARM64 / Surface Pro X)

WSL Version

Kernel Version

5.4.72

Distro Version

No response

Other Software

No response

Repro Steps

C:\> wmic diskdrive list brief
Caption                             DeviceID            Model                               Partitions  Size
WDC WD64 00BEVT-22A0RT0 USB Device  \\.\PHYSICALDRIVE1  WDC WD64 00BEVT-22A0RT0 USB Device  3           640132416000
HFM512GDGTNG-87A0A                  \\.\PHYSICALDRIVE0  HFM512GDGTNG-87A0A                  3           512105932800
C:\>wsl --mount \\.\PHYSICALDRIVE1 --bare
The system cannot find the file specified.

Expected Behavior

A mounted block device in WSL

Actual Behavior

WSL returns The system cannot find the file specified.

Diagnostic Logs

ETL-file captured logs: etl-file.zip

The specific error from the ETL-file seems Hyper-V related:

[
    {
        "ResourcePath": "VirtualMachine/Devices/Scsi/0/Attachments/2",
        "RequestType": "Add",
        "Settings": {
            "Type": "PassThru",
            "Path":"\\\\.\\PHYSICALDRIVE1"
            }
    },
    {
        "Error": -2147024894,
        "ErrorMessage": "The system cannot find the file specified.",
        "ErrorEvents": [
            {
                "Message": "'Virtual Machine': Attachment '\\\\?\\usbstor#disk&ven_wdc_wd64&prod_00bevt-22a0rt0&rev_#20151222&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}' could not be found due to error: 'The system cannot find the file specified.' (0x80070002). (Virtual machine ID A1BB5BC7-228E-4484-83F3-21AC60FADE15)",
                "Provider": "edacd782-2564-4497-ade6-7199377850f2",
                "EventId": 12240,
                "Flags": 5,
                "Data": [
                    {
                        "Type": "String",
                        "Value": "Virtual Machine"
                    },
                    {
                        "Type":"String",
                        "Value": "A1BB5BC7-228E-4484-83F3-21AC60FADE15"
                    },
                    {
                        "Type": "String",
                        "Value":"\\\\?\\usbstor#disk&ven_wdc_wd64&prod_00bevt-22a0rt0&rev_#20151222&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}"
                    },
                    {
                        "Type":"String",
                        "Value":"%%2147942402"
                    },
                    {
                        "Type":"String",
                        "Value":"0x80070002"
                    },
                    {
                        "Type":"String",
                        "Value":"Hyper-V Virtual Machine Management service"
                    },
                    {
                        "Type":"String",
                        "Value":""
                    }
                ]
            }
        ]
    }
]
mahyar1284 commented 3 years ago

I have the same problem

lbssousa commented 3 years ago

Me too

AlfrFerr commented 3 years ago

Same problem here on my Surface Pro X (Windows 11 Pro 22000.318) also trying to mount a vhdx virtual disk:

PS C:\WINDOWS\system32> Write-Output "\\.\PhysicalDrive$((Mount-VHD -Path C:\Users\aferr\Documents\WSL\Ubuntu-20.04-kernel\ext4.vhdx -PassThru | Get-Disk).Number)"
\\.\PhysicalDrive1

PS C:\WINDOWS\system32> Get-WmiObject -query "SELECT * from Win32_DiskDrive"

Partitions : 0
DeviceID   : \\.\PHYSICALDRIVE1
Model      : Disco virtuale Microsoft
Size       : 274872407040
Caption    : Disco virtuale Microsoft

Partitions : 3
DeviceID   : \\.\PHYSICALDRIVE0
Model      : HFM256GDGTNG-87A0A
Size       : 256052966400
Caption    : HFM256GDGTNG-87A0A

S C:\WINDOWS\system32> wsl --mount \\.\PhysicalDrive1
Impossibile trovare il file specificato.

Is it an arm64 related issue?

roshkins commented 2 years ago

Using this alternative worked for me: https://www.scivision.dev/mount-usb-drives-windows-subsystem-for-linux/

AuditeMarlow commented 2 years ago

I'm having the same issue. I'm not suspecting this to be an ARM64 specific problem as I'm currently experiencing this on an AMD64 machine.

PS C:\Windows\system32> GET-WMIOBJECT -query "SELECT * FROM Win32_DiskDrive"

Partitions : 3
DeviceID   : \\.\PHYSICALDRIVE0
Model      : THNSF5512GPUK TOSHIBA
Size       : 512105932800
Caption    : THNSF5512GPUK TOSHIBA

Partitions : 2
DeviceID   : \\.\PHYSICALDRIVE1
Model      : Generic- SD/MMC/MS PRO USB Device
Size       : 3939909120
Caption    : Generic- SD/MMC/MS PRO USB Device

PS C:\Windows\system32> wsl --mount \\.\PHYSICALDRIVE1 --bare
The system cannot find the drive specified.
dmitry-ovon commented 2 years ago

Same problem here...

Windows 10.0.22000 WSL2 5.10.60.1-microsoft-standard-WSL2

C:\Windows\system32> wsl --mount \\.\PHYSICALDRIVE1 --bare
The system cannot find the drive specified.

On top of command not working, it also "Ejects" the drive as a side effect. Any solutions to this?

nirvam commented 2 years ago

Same problem here. Surface Pro 7 Windows 11 22000.556

@dmitry-ovon You can bring back the drive using following command: Set-Disk $n -IsOffline 0 Replace $n with your disk number

timedroid commented 2 years ago

I'm getting the same problem trying to mount an SD card over USB in Windows 11 22000.593

delucca commented 2 years ago

Same thing here while trying to mount an USB disk with 2 partitions (one of them is Lukys encrypted) with ext4 filesystem

I'm on Windows 11 and my CPU has an x86 arch (so, it is not related to ARM)

somadhy commented 2 years ago

Hi all. Same error.

❯ [environment]::OSVersion.Version
Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      22000  0

❯ wsl --update
Checking for updates...
No updates are available.
Kernel version: 5.10.102.1
❯ GET-CimInstance -query "SELECT * from Win32_DiskDrive"

DeviceID           Caption                          Partitions Size          Model
--------           -------                          ---------- ----          -----
\\.\PHYSICALDRIVE5 Generic USB SD Reader USB Device 1          263044454400  Generic USB SD Reader USB Device
\\.\PHYSICALDRIVE6 Generic USB MS Reader USB Device 0                        Generic USB MS Reader USB Device
❯ wsl --mount \\.\PHYSICALDRIVE5
The system cannot find the drive specified.
❯ wsl --mount \\.\PHYSICALDRIVE5 --bare
The system cannot find the drive specified.
rxbrad commented 2 years ago

Same issue here. The removable media (SD card in a USB reader) has a FAT32 partition and an EXT4 partition. It is unmountable on my AMD64 (Ryzen 5600X) machine. Additionally, the drive ejects in Win11 when I attempt the wsl --mount command.

> [environment]::OSVersion.Version
Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      22000  0

> wsl --update
Checking for updates...
No updates are available.
Kernel version: 5.10.102.1

> GET-CimInstance -query "SELECT * from Win32_DiskDrive"
DeviceID           Caption                      Partitions Size          Model
--------           -------                      ---------- ----          -----
\\.\PHYSICALDRIVE0 T-FORCE TM8FP7001T           3          1000202273280 T-FORCE TM8FP7001T
\\.\PHYSICALDRIVE1 SanDisk SDDR-B531 USB Device 2          32021015040   SanDisk SDDR-B531 USB Device

> wsl --mount \\.\PHYSICALDRIVE1 --bare
The system cannot find the drive specified.
yuhcaesar commented 2 years ago

Same problem here.

Same issue here. The removable media (SD card in a USB reader) has a FAT32 partition and an EXT4 partition. It is unmountable on my AMD64 (Ryzen 5600X) machine. Additionally, the drive ejects in Win11 when I attempt the wsl --mount command.

> [environment]::OSVersion.Version
Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      22000  0

> wsl --update
Checking for updates...
No updates are available.
Kernel version: 5.10.102.1

> GET-CimInstance -query "SELECT * from Win32_DiskDrive"
DeviceID           Caption                      Partitions Size          Model
--------           -------                      ---------- ----          -----
\\.\PHYSICALDRIVE0 T-FORCE TM8FP7001T           3          1000202273280 T-FORCE TM8FP7001T
\\.\PHYSICALDRIVE1 SanDisk SDDR-B531 USB Device 2          32021015040   SanDisk SDDR-B531 USB Device

> wsl --mount \\.\PHYSICALDRIVE1 --bare
The system cannot find the drive specified.
itpropro commented 2 years ago

This issue is already over a year old, any updates @craigloewen-msft ?

craigloewen-msft commented 2 years ago

Tagging @OneBlue here for visibility!

ahmedsabriz commented 2 years ago

I am having the same problem on W11 22622.436 I can mount a device from WSL2 Ubuntu using sudo mount -t drvfs d: /mnt/d. However, I can't find the block file.

orpheustaken commented 2 years ago

Same problem on Win11 (21H2 22000.832), and ArchWSL.

Administrator in C:\Arch
❯ Get-CimInstance -ClassName Win32_Processor | Select-Object -ExcludeProperty "CIM*"

DeviceID Name                                            Caption                             MaxClockSpeed SocketDesignation Manufacturer
-------- ----                                            -------                             ------------- ----------------- ------------
CPU0     AMD Ryzen 3 3200U with Radeon Vega Mobile Gfx   AMD64 Family 23 Model 24 Stepping 1 2600          FP5               AuthenticAMD

Administrator in C:\Arch
❯ GET-CimInstance -query "SELECT * from Win32_DiskDrive"

DeviceID           Caption                       Partitions Size         Model
--------           -------                       ---------- ----         -----
\\.\PHYSICALDRIVE0 ADATA SX6000LNP               3          256052966400 ADATA SX6000LNP
\\.\PHYSICALDRIVE1 Kingston DT 101 II USB Device 1          8027873280   Kingston DT 101 II USB Device

Administrator in C:\Arch
❯ wsl --mount \\.\PHYSICALDRIVE1
The system cannot find the drive specified.

Administrator in C:\Arch
❯ wsl --mount \\.\PHYSICALDRIVE1 --bare
The system cannot find the drive specified.
Amondale commented 2 years ago

In my case, a SDXC card in a reader will neither mount in WSL2 via --mount nor using the /etc/fstab route:

` sudo mount -t drvfs E: /mnt/sd

<4>WARNING: mount: waiting for virtio device... <3>init: (639) ERROR: MountPlan9WithRetry:285: mount drvfs on /mnt/sd (cache=mmap,rw,msize=262144,trans=virtio,aname=drvfs;path=E:;symlinkroot=/mnt/) failed: 2 mount: No such file or directory` It is formatted NTFS, normally not a problem to refer to it as /mnt/e. Linux (dual booted) sees this partition as /dev/mmcblk0p1 and mounts it fine. WSL seems crankier about it ... Here's the output from dmesg, not helpful to me at least: `[ 5.835977] init: (1) ERROR: UtilCreateProcessAndWait:673: /bin/mount failed with status 0x [ 5.835980] 4000 [ 5.835989] init: (1) ERROR: ConfigMountFsTab:2529: Processing fstab with mount -a failed.` Possible (bad) interaction with Antivirus in Windows? Seems that way to me.
frankiee12a9 commented 1 year ago

same problem for me after the updates on 12th January. Still looking for a resolution to it.

OneBlue commented 1 year ago

/logs

ghost commented 1 year ago

Hello! Could you please provide more logs to help us better diagnose your issue?

To collect WSL logs, download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The scipt will output the path of the log file once done.

Once completed please upload the output files to this Github issue.

Click here for more info on logging

Thank you!

frankiee12a9 commented 1 year ago

There are some problems with the Docker desktop that uses WSL 2 backend as the based engine. I do some workaround such remove the linux distro and WSL 2 I'm using and reinstalled it again. However, in the distribution installation step, I got:

Installing, this may take a few minutes... WslRegisterDistribution failed with error: 0x80070002 Error: 0x80070002 The system cannot find the file specified. Press any key to continue...

I've spent several hours tried to troubleshoot it but still stuck on it.

ghost commented 1 year ago

This issue has been automatically closed since it has not had any author activity for the past 7 days. If you're still experiencing this issue please re-open it.

Thank you!

jramsey123 commented 1 year ago

Why was this issue closed? It's still a problem. I can't mount/access an SD Card with wsl. Logs attached.

WslLogs-2023-02-14_16-52-38.zip

dmacgowan-acog commented 1 year ago

This continues to be a problem. (Posting to keep issue open.)

pki791 commented 1 year ago

Have the same problem, i always make an image from the drive, then mount the image as loop, after work i flash the image back to the drive. Will this be ever solved?????

maxboone commented 1 year ago

Why was this issue closed? It's still a problem. I can't mount/access an SD Card with wsl. Logs attached.

Seems to be closed because I didn't reopen it or reply with logs (which I thought I provided in the OP, but seemingly didn't). I'll dust off my Pro X and collect some logs tomorrow and reopen the issue.

bretthacker commented 1 year ago

This exact issue has been reported in various places for over 2 years. It's clear most of these folks are dealing with a Raspberry Pi (SD card, 2 partitions, fat32 and ext4). It's ludicrous that someone in Redmond hasn't taken the 10 minutes necessary to repro this issue then step their code to see what's broken. Of course, fixing it would enable all these people to successfully and easily use a different device with a different OS, so after 40 years, Microsoft is still...Microsoft.

redBlueberry commented 1 year ago

Yes, exact same issue here. Raspberry Pi SD card and The system cannot find the drive specified.

flama90 commented 1 year ago

Yes, exact same issue here. Raspberry Pi SD card and The system cannot find the drive specified.

I have exactly the same problem

SajinPrince commented 1 year ago

I have the same issue using AM5 platform Windows 11. It works on my Intel gigabyte laptop Windows 11. Even when I insert the stick into my notebook it picks up the partition natively in Windows. image

adamjames commented 1 year ago

Posting to reopen this, happens for me too. Surprised there's not an automated test in place to check this functionality given how new WSL2 is. The Microsoft Learn Article documenting this was updated March 20th.

mgzfcam commented 1 year ago

Hi all. I have the same problem and still did not find out how to actually solve it, as far as the built-in SD card reader of my laptop is concerned. However, I found a workaround with an external USB SD Card reader and this awesome video: https://www.youtube.com/watch?v=iyBfQXmyH4o

o-alquimista commented 1 year ago

Unfortunately, this is currently unsupported. From https://learn.microsoft.com/en-us/windows/wsl/wsl2-mount-disk:

If you are looking for guidance on how to connect a USB device (flash drive, SD card reader, etc), see Connect USB devices.

Which indicates the use of a third-party open source utility called usbipd-win.

jglathe commented 1 year ago

Which indicates the use of a third-party open source utility called usbipd-win.

nice

maxboone commented 1 year ago

Unfortunately, this is currently unsupported. From https://learn.microsoft.com/en-us/windows/wsl/wsl2-mount-disk

That explains, cool, and thanks for the usbipd-win link - good stuff!

o-alquimista commented 1 year ago

I'm using it here to decrypt a LUKS-encrypted USB stick. It works good. The only downside is having to compile the WSL kernel with USB storage support.

ruff-huettinger commented 8 months ago

I'm having the same issue: Want to write an image file with Win32 Disk Imager under Win11 from a Raspi SD card, but only the NTFS partition shows up, not the ext4 one. Used to work under Win10 Screenshot 2024-03-12 112110 .

wptaylor commented 6 months ago

Same issue, disappointing it hasn't been fixed in three years.

image

pinballelectronica commented 6 months ago

Haha the internet is packed full of people complaining about this. It's actually hilarious it's taken years. I wonder if Microsoft is doing an experiment to see how long people will keep trying when they won't fix the solution to their bugs. The answers website is spammed with these questions too. In concept it seems fairly trivial to fix this- what would cause an ext4 mount failure? I know Windows generally needs a running driver to access ext filesystems so I presume the solution must be in a driver somewhere. It's definitely not trivial to translate a filesystem although mounting, I think, shouldn't be too hard. I wonder if it's a problem with the partitions? Has anyone succesfully mounted an EXT filesystem via USB with ONE partition? Just curious.. Good luck all, it's like watching paint dry.

Apfelmoes commented 4 months ago

How the fuck has this still not been fixed?

pki791 commented 4 months ago

i overcome it by making image if the drive i want to modify (HddRawCopy), mount it in loop in WSL/Ubuntu, modify, unmount, reimage. What a pain in the ass. Trying to leave windows now, going to macOS or ubuntu.

jglathe commented 4 months ago

yk how I overcame this? I used Linux bare metal :man_shrugging: In my case I used a RPi4 to create the image I wanted to create from WSL first. It has the same arch, was able to do my stuff. Still baffled that this isn't solved. Maybe its an architectural issue with WSL2 VMs.

lmoesch commented 3 months ago

This is still an issue and not "closed" - Same problem here.

maxboone commented 3 months ago

This is still an issue and not "closed" - Same problem here.

Create a new one and tag this, I can't reopen it afaics

pinballelectronica commented 2 months ago

i overcome it by making image if the drive i want to modify (HddRawCopy), mount it in loop in WSL/Ubuntu, modify, unmount, reimage. What a pain in the ass. Trying to leave windows now, going to macOS or ubuntu.

that's hacky as fu*ck but it's clever.

yhaiovyi commented 2 months ago

Why on Earth was it closed?

NilsRo commented 2 months ago

Same problem with RPi image....damn, why its closed...