WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Failed to attach disk 'C:\Program Files\WSL\system.vhd' to WSL2: The system cannot find the file specified.

Open onmywaytoheaven opened this issue 1 year ago • 30 comments

Windows Version

Microsoft Windows [Version 10.0.22631.3155]

WSL Version

2.1.5.0

Are you using WSL 1 or WSL 2?

  • [X] WSL 2
  • [ ] WSL 1

Kernel Version

No response

Distro Version

Ubuntu 20.04

Other Software

No response

Repro Steps

Try to run WSL

Expected Behavior

WSL runs

Actual Behavior

Failed to attach disk 'C:\Program Files\WSL\system.vhd' to WSL2: The system cannot find the file specified.

Diagnostic Logs

No response

onmywaytoheaven avatar Mar 12 '24 13:03 onmywaytoheaven

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

github-actions[bot] avatar Mar 12 '24 13:03 github-actions[bot]

Solved by rolling back to 2.1.4.0

onmywaytoheaven avatar Mar 12 '24 13:03 onmywaytoheaven

Solved by rolling back to 2.1.4.0

Can you please tell me how you roll back? Same issue here and I have been struggling the full day to solve this.

JenniferHem avatar Mar 12 '24 16:03 JenniferHem

Solved by rolling back to 2.1.4.0

Can you please tell me how you roll back? Same issue here and I have been struggling the full day to solve this.

You can download 2.1.4.0 here, run the installer and it will do the job for you.

onmywaytoheaven avatar Mar 12 '24 16:03 onmywaytoheaven

There is no change in behavior between these two versions so I suspect there is some kind of latent issue with upgrade. Looks identical to https://github.com/microsoft/WSL/issues/11069.

@OneBlue - can you take a look?

benhillis avatar Mar 12 '24 16:03 benhillis

Solved by rolling back to 2.1.4.0

Can you please tell me how you roll back? Same issue here and I have been struggling the full day to solve this.

You can download 2.1.4.0 here, run the installer and it will do the job for you.

That hepled! Almost deleted my wsl. Thanks

VolodymyrKaznacheiev avatar Mar 12 '24 18:03 VolodymyrKaznacheiev

Thanks a lot @benhillis as I have no admin rights I really hope our IT Support is quick. @VladimirKaznacheiev I feel you, good that I do not have Admin rights :D

JenniferHem avatar Mar 13 '24 07:03 JenniferHem

Solved by rolling back to 2.1.4.0

Can you please tell me how you roll back? Same issue here and I have been struggling the full day to solve this.

You can download 2.1.4.0 here, run the installer and it will do the job for you.

this is perfect.

tried everything from rolling back windows update to local security policy and regedit. Thank you !

aclerc-blachere avatar Mar 13 '24 16:03 aclerc-blachere

Solved by rolling back to 2.1.4.0

Good afternoon, unfortunately the reinstallation did not help me, do you know what else I can try?

изображение

изображение

Docker itself updates to the latest version of wsl, don’t know how to disable it?

Romakip avatar Mar 16 '24 18:03 Romakip

No expert here. My docker desktop or WSL2 wouldn't start yesterday after working just hours before. I got the same error message. I only had some 4-5 files in C:\Program Files\WSL, and system.vhd was not there.

As part of troubleshooting I did uninstall docker-desktop first. But I guess that was not needed. I did install the 2.1.4 installer linked in this post. After that, I had lots of files in C:\Program Files\WSL, including system.vhd. Then I re-installed docker-desktop. After that, I had WSL 2 working again.

# output after installing 2.1.4 install file and re-installing docker-desktop 
PS C:\ wsl --version
WSL version: 2.1.4.0
Kernel version: 5.15.146.1-2
WSLg version: 1.0.60
MSRDC version: 1.2.5105
Windows version: 10.0.19045.4046

Maybe using 2.1.5 installer would has worked just as well, I didn't test. Might not have needed to re-install docker-desktop.

No idea what caused what seems like removing existing system.vhd and supporting files (if that happened). When WSL2 was not working anymore and I looked in C:\Program Files\WSL, I didn't have many files there, I just had like 4-5 files in that directory, plus some folders with log files and a few small size files.

I didn't install anything myself lately. I do have docker-desktop, but it doesn't auto-update for me. My IT dept said no rollouts was made recently.

So still no idea what caused this for me. I guess I'm happy it works now after this scare, and this post helped.

joelhellman avatar Mar 19 '24 01:03 joelhellman

Thank you @joelhellman. Out of curiosity, do you have a .wslconfig ? If so can you share its contents ?

OneBlue avatar Mar 19 '24 07:03 OneBlue

@OneBlue sure, here is my full unedited .wslconfig (it has been unchanged for about a year)

# Settings apply across all Linux distros running on WSL 2
[wsl2]
# guiApplications=false

# Limits VM memory
memory=12GB

joelhellman avatar Mar 24 '24 13:03 joelhellman

Very happy with the suggestion of installing 2.1.4 since that instantly brought my WSL back to life, many many thanks.

Very unhappy with this critical bug in a patch version being around for more than two months without being addressed. Most people using WSL will be developers or students that rely on WSL working properly. These situations make me want to buy a Macbook.

ostecke avatar May 29 '24 09:05 ostecke

Neither installing 2.1.4 nor 2.1.5 fixed the problem for me (was using the msix installer). I just copied the files from its old location C:\ProgramData\Microsoft\WSL to the new location C:\Program Files\WSL with elevated rights, and it was working again. I made sure, that this procedure did not overwrite existing files (some of them were already there).

mx-bernhard avatar Jun 04 '24 08:06 mx-bernhard

Faced similar issue after upgrading from 2.2.1 to 2.2.4.msi. It looks like it's picking up some default vhd path. I checked wsl.exe --list which still shows my default distro as (Default). I then tried wsl.exe --distribution mydistro which didn't work.

I then installed 2.2.3, did a wsl.exe --shutdown and somehow it worked.

curbengh avatar Jul 12 '24 08:07 curbengh

Downgraded per https://github.com/microsoft/WSL/issues/11288#issuecomment-1992080697 above, and I was able regain access to my work-sensitive data in my WSL instance. Immediately backed up the sensitive data and will create encrypted backups of it (off system and off site).

Xuroth avatar Oct 04 '24 21:10 Xuroth

@onmywaytoheaven Is there any way to force Windows to reinstall the WSL package to restore (reinstall) the C:\Program Files\WSL\system.vhd file?

Thank you. I ran into that problem today. Your solution is very helpful. Have a great day!

artyomboyko avatar Nov 13 '24 12:11 artyomboyko

@onmywaytoheaven Is there any way to force Windows to reinstall the WSL package to restore (reinstall) the C:\Program Files\WSL\system.vhd file?

Thank you. I ran into that problem today. Your solution is very helpful. Have a great day!

I had the same issue due to windows updating yesterday. Downgrading to the previous working version works for me as others have suggested, it seems to install the system.vhd file appropriately.

  • For me, I had to downgrade from 2.3.26.0 -> 2.3.24.0
  • 2.3.26.0 was released November 10th, 2024 (5 days ago from this post)
  • I skipped downgrading to 2.3.25.0 as it is tagged as a pre-release
  • So I chose 2.3.24.0 as it was released September 27th, 2024 (3 weeks ago from this post)

Steps to fix:

  1. Find your current version (which isn't working)
  2. Download the most recent working version msi installer file
  3. Run the msi
  4. Check your WSL2 distro is working again

1. Find your current version (which isn't working)

  • Here I can see my broken version is 2.3.26.0
wsl --version
WSL version: 2.3.26.0
Kernel version: 5.15.167.4-1
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.22631.4460

2. Download the most recent working version msi installer file

  • Download from https://github.com/microsoft/WSL/releases
  • Check the dates of the release and choose one that was released prior to your version being broken
  • Note: Do not download any versions marked pre-release

3. Run the msi

  • Run the msi file (double click to execute)

4. Check your WSL2 distro is working again

  • Open the terminal
  • Note: My updated working version is now 2.3.24.0
wsl --version
WSL version: 2.3.24.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.22631.4460

adriantorrie avatar Nov 14 '24 22:11 adriantorrie

@onmywaytoheaven Is there any way to force Windows to reinstall the WSL package to restore (reinstall) the C:\Program Files\WSL\system.vhd file? Thank you. I ran into that problem today. Your solution is very helpful. Have a great day!

I had the same issue due to windows updating yesterday. Downgrading to the previous working version works for me as others have suggested, it seems to install the system.vhd file appropriately.

  • For me, I had to downgrade from 2.3.26.0 -> 2.3.24.0
  • 2.3.26.0 was released November 10th, 2024 (5 days ago from this post)
  • I skipped downgrading to 2.3.25.0 as it is tagged as a pre-release
  • So I chose 2.3.24.0 as it was released September 27th, 2024 (3 weeks ago from this post)

Steps to fix:

  1. Find your current version (which isn't working)
  2. Download the most recent working version msi installer file
  3. Run the msi
  4. Check your WSL2 distro is working again

1. Find your current version (which isn't working)

  • Here I can see my broken version is 2.3.26.0

wsl --version WSL version: 2.3.26.0 Kernel version: 5.15.167.4-1 WSLg version: 1.0.65 MSRDC version: 1.2.5620 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.26100.1-240331-1435.ge-release Windows version: 10.0.22631.4460

2. Download the most recent working version msi installer file

  • Download from https://github.com/microsoft/WSL/releases
  • Check the dates of the release and choose one that was released prior to your version being broken
  • Note: Do not download any versions marked pre-release

3. Run the msi

  • Run the msi file (double click to execute)

4. Check your WSL2 distro is working again

  • Open the terminal
  • Note: My updated working version is now 2.3.24.0

wsl --version WSL version: 2.3.24.0 Kernel version: 5.15.153.1-2 WSLg version: 1.0.65 MSRDC version: 1.2.5620 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.26100.1-240331-1435.ge-release Windows version: 10.0.22631.4460

The problem I encountered is exactly the same as what you described. Thank you so much for the tutorial on fixing it. It's really great!

zbwj66 avatar Nov 18 '24 07:11 zbwj66

Same problem here right now.

Updated with wsl --update and restarted following the doc: installing systemd.

Had this problem.

PS C:\Users\bbc> wsl Failed to attach disk 'C:\Program Files\WSL\system.vhd' to WSL2: The system cannot find the file specified. Error code: Wsl/Service/CreateInstance/CreateVm/MountVhd/HCS/ERROR_FILE_NOT_FOUND after update

Had to downgrade to 2.1.4. Just installing that worked.

stefanorossiti avatar Mar 04 '25 12:03 stefanorossiti

Same problem just happened to me. The trigger seemed to be a restart to install windows updates (sadly my org has set these to be automatic, so they sometimes happen without sufficient warning) while WSL was running. I'm not sure if WSL itself was updated by this but it was definitely broken afterwards.

The WSL version after the reboot (in the broken state) was 2.4.12.0, and reinstalling 2.4.11.0 seemed to recover the disk. I suspect it's not any particular upgrade/downgrade that fixes it, just forcing a reinstall (and running the same-version MSI does not reinstall).

So the real bug is that there are conditions that apparently corrupt/delete that disk. I'd be considerably more livid if this could also occur to the actual distribution disk, but at least in this case it appeared to be safe.

gavinltomra avatar Mar 12 '25 00:03 gavinltomra

Same here. Update policy of my company suddenly restarted my PC without any warning, after that WSL stopped working. I don't know what version I had before, but the 2.4.12 was not working, and installing the previous one, 2.4.11 fixed the problem.

kamichal avatar Mar 12 '25 14:03 kamichal

Same here. Update policy of my company suddenly restarted my PC without any warning, after that WSL stopped working. I don't know what version I had before, but the 2.4.12 was not working, and installing the previous one, 2.4.11 fixed the problem.

The same thing happened to me this morning. Swapping to 2.4.11 fixed it here as well.

bpratt-uncomn avatar Mar 13 '25 16:03 bpratt-uncomn

Same here. Update policy of my company suddenly restarted my PC without any warning, after that WSL stopped working. I don't know what version I had before, but the 2.4.12 was not working, and installing the previous one, 2.4.11 fixed the problem.

The same thing happened to me this morning. Swapping to 2.4.11 fixed it here as well.

Confirming that WSL was running when my computer auto-updated. Coming back up, this error occurred. Downgrading to 2.4.11 (from 2.4.12) fixed the issue.

I was also able to upgrade from 2.4.11 back to 2.4.12 and things are also still working and no data loss.

plabbett avatar Mar 14 '25 02:03 plabbett

I encountered a similar issue with version 2.4.13, and I was able to resolve it by downgrading to version 2.4.11.

jbrathwa avatar Mar 27 '25 09:03 jbrathwa

I encountered a similar issue with version 2.4.13, and I was able to resolve it by downgrading to version 2.4.11.

Same thing here. I will try to downgrade.

EDIT : Downgrading to WSL 2.4.11 is a solution. It prevented me from starting my IntelliJ... Glad I found this post !

mathisgauthey avatar Mar 27 '25 10:03 mathisgauthey

Same issue here. Worked by downgrading from 2.4.13 to 2.4.11 AND performing a reboot of the machine.

dosif avatar Apr 02 '25 10:04 dosif

I upgraded from WSL 2.4.13 to WSL 2.5.7 in Windows 11, by "wsl --update" but encountered the issue: "Failed to attach disk 'C:\Program Files\WSL\system.vhd' to WSL2"

Fix Method:

  1. Download wsl.2.5.7.0.x64.msi from github
  2. Shift + Right-click the MSI file
  3. Select "Repair (P)"

After the repair completes, 'C:\Program Files\WSL\system.vhd' will be available.

syuuha avatar May 28 '25 03:05 syuuha

I upgraded from WSL 2.4.13 to WSL 2.5.7 in Windows 11, by "wls --update" but encountered the issue: "Failed to attach disk 'C:\Program Files\WSL\system.vhd' to WSL2"

Fix Method:

  1. Download wsl.2.5.7.0.x64.msi from github
  2. Shift + Right-click the MSI file
  3. Select "Repair (P)"

After the repair completes, 'C:\Program Files\WSL\system.vhd' will be available.

This also fixed it for me.

joey-bolts avatar May 28 '25 10:05 joey-bolts

I upgraded from WSL 2.4.13 to WSL 2.5.7 in Windows 11, by "wsl --update" but encountered the issue: "Failed to attach disk 'C:\Program Files\WSL\system.vhd' to WSL2"

Fix Method:

1. Download wsl.2.5.7.0.x64.msi from github

2. Shift + Right-click the MSI file

3. Select "Repair (P)"

After the repair completes, 'C:\Program Files\WSL\system.vhd' will be available.

Thank you so much! It works!

kresnasatya avatar Jun 11 '25 05:06 kresnasatya