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
- uninstall the old kali linux
- 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
>wsl --unregister ubuntufollowed by>wsl --installfixes the problem for ubuntu atleastI 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!
it worked for me, thanks alot
It does also for kali wsl --unregsiter kali-linux
Agreed. Same issue. This is the way.
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 0xffffffffSolved it with just
wsl --unregister docker-desktopand then restarting DockerWARNING:
wsl --unregister ubuntuMAY REMOVE USER DATAIf you unintentionally run it:
wsl --mount --vhd <pathToVHD>, or following https://github.com/microsoft/WSL/issues/4762#issuecomment-678792777.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.vhdxdisk 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 wasSystemin 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
same problem here,
wsl --unregister docker-desktopand restart Docker Desktop just work! thanks @Fabienjulio … no data was lost btwIt’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 ubuntufollowed by reinstall from ms store also worked.Yes. It wiped my data in wsl.
it is 2024 and this works for me!
wsl --unregister ubuntu wsl -- installI 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 --unregisterfollowed bywsl --install- does this not result in data loss??Still works, thank you!
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
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
On point! Thanks!