microsoft / WSL

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

Plan9FileSystem hogging external USB drive with open handle #7972

Open cbeuw opened 2 years ago

cbeuw commented 2 years ago

Version

WSL version: 0.51.2.0 Kernel version: 5.10.81.1 WSLg version: 1.0.30 Windows version: 10.0.22000.434

WSL Version

Kernel Version

No response

Distro Version

No response

Other Software

No response

Repro Steps

Don't know exactly how to reproduce, but right now there is a dllhost.exe having an open handle on D:\ (which is an external USB drive) and preventing it from ejecting.

It was started with the commandline C:\WINDOWS\system32\DllHost.exe /Processid:{DFB65C4C-B34F-435D-AFE9-A86218684AA8}, a registry search pointed to HKEY_CLASSES_ROOT\CLSID\{AFC7B6DE-D642-41B7-AB0C-A01019510741} which has an entry named Plan9FileSystem so it's probably WSL2 related.

image

The handle is still open after wsl --shutdown.

Expected Behavior

WSL2 file system bridge should not prevent external drives from ejecting

Actual Behavior

External drives cannot be ejected

Diagnostic Logs

No response

atruskie commented 2 years ago

I just ran into this as well:

The application \Device\HarddiskVolume6\Windows\System32\dllhost.exe with process id 26064 stopped the removal or ejection for the device USB\VID_1058&PID_25A3\575837324437314644415045.
Process command line: C:\WINDOWS\system32\DllHost.exe /Processid:{DFB65C4C-B34F-435D-AFE9-A86218684AA8}
List of affected devices:

WSL version: 0.51.2.0 Kernel version: 5.10.81.1 WSLg version: 1.0.30 Windows version: 10.0.22538.1010

kogereneliteness commented 2 years ago

I also have this problem. The DLLHost. With Proccessid {DFB65C4C-B34F-435D-AFE9-A86218684AA8} locks my external drive, even this drive have NEVER been used by WSL.

Win 10 21H2: 19044.2006 WSL Kernel: 5.10.16

Also why are you (WSL devs) running this under a dllhost.exe, it seems like a bad approach. When I need to troubleshoot my PC, I do not want to go lookup GUIDs in the hunt of the actual problem in context of a dllhost.

What is the reason for this?

PabloRomanH commented 1 year ago

Is a fix for this in the horizon? Right now I have to keep killing dllhost.exe, then executing it again after ejecting the drive, and then I need to reboot WSL for it to get back access to Window's filesystem.

dingjibang commented 1 year ago

same issue on win11

DllHost.exe /Processid:{DFB65C4C-B34F-435D-AFE9-A86218684AA8}

WSL version: 1.1.3.0 Kernel version: 5.15.90.1 WSLg version: 1.0.49 MSRDC version: 1.2.3770 Direct3D version: 1.608.2-61064218 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22621.1265

Argimko commented 1 year ago

You can try the following: open \\wsl.localhost\<linux_dist>\etc\wsl.conf and add the following:

[automount]
enabled = false

Reference: https://learn.microsoft.com/en-us/windows/wsl/wsl-config#automount-settings

But is doesn't work for my Docker Container, because Docker Desktop rewrite wsl.conf after restart, and I don't know where I can adjust appropriate Docker setting to disable automount.

m4heshd commented 8 months ago

This is incredibly annoying. Shutting down WSL allowed me to safely remove the drive though.