microsoft / WSL

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

WSL cannot mount VHD located on network share (smb) #7803

Open DenizThatMenace opened 2 years ago

DenizThatMenace commented 2 years ago

Version

10.0.22000.318

WSL Version

Kernel Version

5.10.74.3

Distro Version

Ubuntu 20.04

Other Software

No response

Repro Steps

Pre-requisite:

Steps to reproduce the problem:

  1. Create a virtual hard drive in VHD or VHDX format on that network drive (e.g. using Windows Disk Management). (Size and if dynamically or statically allocated does not matter.)
  2. In PowerShell or cmd.exe try to mount that virtual hard drive using wsl.exe:
    wsl.exe --mount  <path-to-vhd(x)-on-network-drive>  --vhd --bare
  3. Read the resulting error message.
    In German it reads:
    Der angegebene Server kann den angeforderten Vorgang nicht ausführen.

    Roughly translated it means:

    The specified server cannot perform the requested operation.

Steps for a workaround:

  1. Mount the virtual hard drive into Windows using PowerShell, thereby printing the mount name:
    Write-Output "\\.\PhysicalDrive$((Mount-VHD -Path  <path-to-vhd(x)-on-network-drive>  -PassThru | Get-Disk).Number)"

    Note: For the following command we assume this prints the following as the mount name:

    \\.\PhysicalDrive2
  2. Mount this "physical drive" into WSL:
    wsl.exe --mount \\.\PhysicalDrive2 --bare
  3. Go into your WSL Linux and verify that it was successfully mounted by calling lsblk.

Expected Behavior

Mounting a VHD or VHDX file from a network share should succeed as it does from a local drive.

Actual Behavior

Mounting a VHD or VHDX file from a network share does not succeed as demonstrated above.

Diagnostic Logs

No response

DenizThatMenace commented 2 years ago

Some additional information as requested in the CONTRIBUTING.md file:

Additional information:

wmic diskdrive get Availability,Capabilities,CapabilityDescriptions,DeviceID,InterfaceType,MediaLoaded,MediaType,Model,Name,Partitions
Availability  Capabilities  CapabilityDescriptions                 DeviceID            InterfaceType  MediaLoaded  MediaType              Model                                Name                Partitions
                                                                   \\.\PHYSICALDRIVE1  USB            TRUE                                Generic- SD/MMC/MS/MSPRO USB Device  \\.\PHYSICALDRIVE1  0
              {3, 4}        {"Random Access", "Supports Writing"}  \\.\PHYSICALDRIVE0  SCSI           TRUE         Fixed hard disk media  SAMSUNG MZVLB1T0HBLR-000L7           \\.\PHYSICALDRIVE0  5
              {3, 4}        {"Random Access", "Supports Writing"}  \\.\PHYSICALDRIVE2  SCSI           TRUE         Fixed hard disk media  Microsoft Virtual Disk               \\.\PHYSICALDRIVE2  0

Note: This is the output after mounting the VHD file into Windows (with the above mentioned workaround).

OneBlue commented 2 years ago

/logs

ghost commented 2 years ago

Hello! Could you please provide more logs to help us better diagnose your issue? You can find instructions on how to attach logs here, please make sure to post the link to the Feedback Hub item in this chat so we can see it.

Thank you!

DenizThatMenace commented 2 years ago

I uploaded the feedback: https://aka.ms/AAf41h2

OneBlue commented 2 years ago

Thank you @Bagira80, I don't see any logs in that feedback hub entry though.

Can you try the 'Record WSL logs manually' section ?

DenizThatMenace commented 2 years ago

Could it be that I need to set some specific Windows / Registry settings in order to collect (more) information? Luckily, I originally also created manual WSL logs.

However, I am unable to attach them to the original ticket. (I seem to only be able to write a comment but not to upload anything.
Therefore I created a new Feedback Hub entry but marked it as relative to the original one and attached the manual logs there. As the result I got the same link: https://aka.ms/AAf41h2

I hope that works now.

OneBlue commented 2 years ago

Sorry @Bagira80 I'm still not seeing any logs on that ticket. Can you try to attach the manual logs to this issue instead ?

DenizThatMenace commented 2 years ago

Sure, here you go: wsl.etl.zip

Note, I had to compress it into a zip file because Github did not like/support uploading the original file type.

OneBlue commented 2 years ago

Thanks for the logs @Bagira80.

The error comes from the hyper-V storage driver:

1723    False   Microsoft.Windows.HyperV.StorageActivity    SynthStorAttachmentPowerOn  2   12-07-2021 14:21:41.395 "   "   "wilActivity: 
{
    hresult:    0x8007003A
    threadId:   4596
}"              13236   4596    4       14d2b994-ebb7-0002-fa57-d314b7ebd701        

It indeed doesn't look like UNC paths are supported when VHD's are attached to guests. Given that mounting the VHD in Windows works, it's something that WSL could eventually do automatically for UNC paths, so I'll leave this open since it could be a feature for wsl --mount.