WSL: Failed to attach disk 'LocalState\ext4.vhdx' to WSL2: The system cannot find the file specified.

Windows Version

Microsoft Windows [Version 10.0.22621.1555]

WSL Version

1.2.5.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

Linux version 5.15.90.1-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220) #1 SMP Fri Jan 27 02:56:13 UTC 2023

Distro Version

Kali linux

Other Software

No response

Repro Steps

  1. uninstall the old kali linux
  2. reinstall kali linux from ms store.

Expected Behavior

The Kali linux installed successfully.

Actual Behavior

Could not open/start it when installed finished.

Diagnostic Logs

Failed to attach disk 'C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalState\ext4.vhdx' to WSL2: The system cannot find the file specified.
Error code: Wsl/Service/CreateInstance/MountVhd/ERROR_FILE_NOT_FOUND
Press any key to continue...
C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg>du -v

DU v1.62 - Directory disk usage reporter
Copyright (C) 2005-2018 Mark Russinovich
Sysinternals - www.sysinternals.com

           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\AC\INetCache
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\AC\INetCookies
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\AC\INetHistory
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\AC\Temp
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\AC
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\AppData
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalCache\Local\Microsoft
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalCache\Local
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalCache\Roaming\Microsoft\Windows\Start Menu\Programs
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalCache\Roaming\Microsoft\Windows\Start Menu
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalCache\Roaming\Microsoft\Windows
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalCache\Roaming\Microsoft
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalCache\Roaming
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalCache
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalState
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\RoamingState
           8  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\Settings
          32  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\SystemAppData\Helium
          32  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\SystemAppData
           0  C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\TempState

Totals:
Files:        8
Directories:  21
Size:         40,960 bytes
Size on disk: 135,168 bytes


C:\Users\Liu.D.H\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg>

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 16
  • Comments: 59

Most upvoted comments

>wsl --unregister ubuntu followed by >wsl --install fixes the problem for ubuntu atleast

I can confirm, a simple reinstallation via Microsoft Store does not work, but wsl unregister and then install does.

Hello, I’m new to this computer stuff but I had this issue too. Couldn’t find anything except a short 2min YT video. Basically you need to re-install and run your Unix installation through Powershell first.

Steps: run Windows Powershell as Admin wsl --uninstall kali-linux wsl --install --distribution kali-linux

This will run kali-linux in the Powershell terminal. You can just close the Powershell terminal then run the app from the store. Not sure how or why it works but it worked for me. Hope this helps you and whoever encounters this!

>wsl --unregister ubuntu followed by >wsl --install fixes the problem for ubuntu atleast

it worked for me, thanks alot

>wsl --unregister ubuntu followed by >wsl --install fixes the problem for ubuntu atleast

It does also for kali wsl --unregsiter kali-linux

I can confirm, a simple reinstallation via Microsoft Store does not work, but wsl unregister and then install does.

Agreed. Same issue. This is the way.

Works (as of 11/09/2023): wsl --unregister ubuntu wsl – install

Thanks a lot! I had the same problem but with Docker Desktop provisioning docker WSL distros: ensuring main distro is deployed: checking if main distro is up to date: checking main distro bootstrap version: getting main distro bootstrap version: exit code: 4294967295: running WSL command wsl.exe C:\Windows\System32\wsl.exe -d docker-desktop -u root -e wsl-bootstrap version: Échec de l’attachement du disque « <HOME>\AppData\Local\Docker\wsl\distro\ext4.vhdx » à WSL2. Error code: Wsl/Service/CreateInstance/MountVhd/HCS/ERROR_FILE_NOT_FOUND : exit status 0xffffffff

Solved it with just wsl --unregister docker-desktop and then restarting Docker

WARNING: wsl --unregister ubuntu MAY REMOVE USER DATA

If you unintentionally run it:

  • Try finding your old files in AppData\Local\Packages. My files were in CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc, which is thankfully different from the newly installed CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc.
  • Recover your files by either mounting them in a new WSL distro with wsl --mount --vhd <pathToVHD>, or following https://github.com/microsoft/WSL/issues/4762#issuecomment-678792777.

It’s kind of obvious that loosing all your work would fix it guys. But what’s the solution when we can’t/don’t want to lose all the data???

TL;DR: Go to “Turn windows features on and off” -> uncheck windows subsystem for linux -> restart -> do it again and check the windows subsystem for linux box and after restarting again you are good to go.

I had the same issue as OP, I tried moving my ext4.vhdx disk file, in an attempt to free it from whatever process was using it, it denied this action but also told me which process was using this file, it was System in my case, so I tried the steps described on my tldr and it worked, without losing data or any side effects.

I also tried other solutions which didn’t work: Signing out of my user, restarting, closing other processes.

Hope this helps.

Works (as of 11/09/2023): wsl --unregister ubuntu wsl – install

Thanks a lot! I had the same problem but with Docker Desktop provisioning docker WSL distros: ensuring main distro is deployed: checking if main distro is up to date: checking main distro bootstrap version: getting main distro bootstrap version: exit code: 4294967295: running WSL command wsl.exe C:\Windows\System32\wsl.exe -d docker-desktop -u root -e wsl-bootstrap version: Échec de l’attachement du disque « <HOME>\AppData\Local\Docker\wsl\distro\ext4.vhdx » à WSL2. Error code: Wsl/Service/CreateInstance/MountVhd/HCS/ERROR_FILE_NOT_FOUND : exit status 0xffffffff

Solved it with just wsl --unregister docker-desktop and then restarting Docker

same problem here, wsl --unregister docker-desktop and restart Docker Desktop just work! thanks @Fabienjulio … no data was lost btw

It’s kind of obvious that loosing all your work would fix it guys. But what’s the solution when we can’t/don’t want to lose all the data???

> wsl --unregister ubuntu followed by reinstall from ms store also worked.

For those doing wsl --unregister followed by wsl --install - does this not result in data loss??

Yes. It wiped my data in wsl.

it is 2024 and this works for me!

wsl --unregister ubuntu wsl -- install

I achieved after running the commands wsl --unregister ubuntu and wsl --instal

after uninstalling ubuntu from the microsoft store and installing again

For those doing wsl --unregister followed by wsl --install - does this not result in data loss??

>wsl --unregister ubuntu followed by >wsl --install fixes the problem for ubuntu atleast

Still works, thank you!

>wsl --unregister ubuntu followed by >wsl --install fixes the problem for ubuntu atleast

thanks. it’s working!

This is usually an issue with your rights, ensure you have sufficient rights to the vhdx file. Which you probably don’t have since this file most likely was moved from another computer. E.g image

Ah NVM, https://github.com/microsoft/WSL/issues/9349#issuecomment-1379447153 solved my problem

I hope in the future this process will be done automatically when updating the user directory.

in pws: wsl --unregister kali-linux

wsl --install kali-linux

>wsl --unregister ubuntu followed by >wsl --install fixes the problem for ubuntu atleast

On point! Thanks!