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

wslbridge2 and WSLtty cannot start due to ERROR_SHARING_VIOLATION on vhdx file #10543

Open
1 of 2 tasks
me-and opened this issue Sep 26, 2023 · 12 comments
Open
1 of 2 tasks

Comments

@me-and
Copy link
Member

me-and commented Sep 26, 2023

Windows Version

Microsoft Windows [Version 10.0.22631.2338]

WSL Version

2.0.0.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.123.1-microsoft-standard-WSL2

Distro Version

Debian trixie

Other Software

WSLtty 3.6.1.2

Repro Steps

Since a recent Windows or WSL update1, attempting to use WSL via WSLtty fails.

Repro steps:

  • Take a working WSL Debian installation
  • Install WSLtty: download and run wsltty-3.6.5-x86_64-install.exe from https://github.com/mintty/wsltty/releases/tag/3.6.5
  • Run the new "Debian Terminal" shortcut from the Start Menu, or run C:\Users\adinwoodie\AppData\Local\wsltty\bin\mintty.exe --WSL="Debian" --configdir="C:\Users\adinwoodie\AppData\Roaming\wsltty" -~ - from the Run dialog

Expected Behavior

I get a WSLtty terminal I can use to access my Debian WSL installation.

Actual Behavior

The WSLtty window appears for a fraction of a second, then disappears.

Diagnostic Logs

Running WSLtty as C:\Users\adinwoodie\AppData\Local\wsltty\bin\mintty.exe --WSL="Debian" --configdir="C:\Users\adinwoodie\AppData\Roaming\wsltty" -~ -h always - – i.e. with the window set to not automatically close – produces a window with the following error message:

/bin/wslbridge2: Exit 1.
note: wsl.exe output: Failed to attach disk 'C:\Users\adinwoodie\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\ext4.vhdx' to WSL2: The process cannot access the file because it is being used by another process.
Error code: Wsl/Service/CreateInstance/MountVhd/HCS/ERROR_SHARING_VIOLATION

I'll send the WSL logs in by email shortly.

Footnotes

  1. This was working fine yesterday, 25 September 2023, and is failing today, 26 September 2023, although I hadn't booted my computer for approximately three weeks prior to 25 September, so there were a relatively large number of updates to install; the full list of installed updates for me per Windows Update is at wsltty won't start with wsl2 version 2.0.0 mintty/wsltty#342.

@mcdonnnj
Copy link

mcdonnnj commented Oct 2, 2023

Per mintty/wsltty#342 (comment) it looks like it's a change in an undocumented interface.

@Malix-off
Copy link

I got the same problem with Ubuntu.

@Ricaz
Copy link

Ricaz commented Nov 14, 2023

I'm suddenly having the same issue on my work PC, however just trying to start WSL normally causes the error.

m:\>wsl
Disken 'C:\wsl\arch\ext4.vhdx' kunne ikke tilsluttes WSL2: The process cannot access the file because it is being used by another process.
Error code: Wsl/Service/CreateInstance/MountVhd/HCS/ERROR_SHARING_VIOLATION

Version info:

c:\>wsl --version
WSL-version: 2.0.9.0
Kerneversion: 5.15.133.1-1
WSLg-version: 1.0.59
MSRDC-version: 1.2.4677
Direct3D-version: 1.611.1-81528511
DXCore-version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows-version: 10.0.19045.3570

I tried looking up file handles with the Resource Monitor and Process Explorer, but I can't find anything using the file.

I've had a few successes with launching WSL through cmd.exe and the Arch.exe that came with my installer, and it seems like waiting a few minutes after running wsl --shutdown can help. Still haven't been able to launch it through WSLtty, though.

@barrykester
Copy link

barrykester commented Nov 15, 2023

Same issue as the above user "Ricaz" with the same version after a Windows update of "Windows Subsystem for Linux" last night:

WSL-version: 2.0.9.0

Emitted mintty.exe with a -log option and get:

note: wsl.exe output: Failed to attach disk 'C:\Users\MYUSERNAME\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState\ext4.vhdx' to WSL2: The process cannot access the file because it is being used by another process.
Error code: Wsl/Service/CreateInstance/MountVhd/HCS/ERROR_SHARING_VIOLATION

I'm able to invoke wsl.exe via the cmd prompt without issue.

@jonzerstyle
Copy link

Same issue here after windows update today.

wsl --version
WSL version: 2.0.9.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.3693

wsl --list
Windows Subsystem for Linux Distributions:
Ubuntu-18.04 (Default)

.\mintty.exe --version
pop up dialog indicates 3.6.4 @2023

@barrykester
Copy link

barrykester commented Nov 16, 2023

So, after replacing the wsltty binaries with version 3.7.0 (from 3.6.4) and getting a similar yet different error:

ERROR: GetVmId:318: CreateLxProcess: The process cannot access the file because it is being used by another process.

I downgraded by Ubuntu container to wsl version 1 with:

wsl --list --verbose

#note the Ubuntu name then:

wsl --set-version [Ubuntu name] 1

This may cause other unknown issues, but it seems to have solve this particular issue. Another thread alludes to WSL version 2 compatibility issues. Apparently wslbridge2.exe is hooking into undocumented API calls within WSL version 2 (likely using LoadLibrary and GetProcAddress) and Microsoft is changing API points and behaviour under the hood. Who knows what is happening here -- I certainly do not.

@jonzerstyle
Copy link

I became desperate and started looking around for an alternative to WSL Terminal. Windows Terminal from the app store works very nicely. You can set it to launch your WSL VM by default in the settings. The colors look right in vim. The font it uses by default looks great to me. Supports hot keys for tabbing. The interface seems simpler and cleaner than ConEmu. I like it so far.

@Ricaz
Copy link

Ricaz commented Nov 17, 2023

I became desperate and started looking around for an alternative to WSL Terminal. Windows Terminal from the app store works very nicely. You can set it to launch your WSL VM by default in the settings. The colors look right in vim. The font it uses by default looks great to me. Supports hot keys for tabbing. The interface seems simpler and cleaner than ConEmu. I like it so far.

I ended up doing the same. It has a lot of annoying Windows hotkeys by default, but after removing most of them, it works okay.

Only thing is it feels really heavy and laggy, where mintty is super responsive and light.

When it just worked out of the box, I became a bit suspicious that Microsoft might intentionally be blocking alternatives..

@ypnos
Copy link

ypnos commented Nov 20, 2023

I have the same issue as described with wsltty 3.7.0, WSL 2.0.9.2 on Windows 10.0.19044.3570

And I don't want to switch away from wsltty 😿

@l1n3n01z
Copy link

l1n3n01z commented Nov 22, 2023

wslbridge2 has been updated to handle the API change. wsltty is not yet updated but just replacing the wslbridge2.exe with the nightly cygwin build will fix the issue.

See discussion here mintty/wsltty#343

@ypnos
Copy link

ypnos commented Nov 24, 2023

Works again with wsltty-3.7.0.2

@neilborromeo
Copy link

What happened to me was that I accidentally double-clicked the VHD file and Windows mounted it automatically. I detached it via Computer Management > Disk Management and there's an offline VHD disk attached. I believe I marked it as offline at first too via dispark where I usually do compact disk.

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

9 participants