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?
- [X] 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>
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
I can confirm, a simple reinstallation via Microsoft Store does not work, but wsl unregister and then install does.
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.
>wsl --unregister ubuntufollowed by>wsl --installfixes the problem for ubuntu atleast
it worked for me, thanks alot
>wsl --unregister ubuntufollowed by>wsl --installfixes the problem for ubuntu atleast
On point! Thanks!
>wsl --unregister ubuntufollowed by>wsl --installfixes the problem for ubuntu atleast
It does also for kali wsl --unregsiter kali-linux
Can confirm the unregister and install works. Saved my backside today.
I can confirm, a simple reinstallation via Microsoft Store does not work, but wsl unregister and then install does.
This is it 👍
This fixed it. Thank you
i have it loading, its saying installing ubuntu, im worried.
> wsl --unregister ubuntu
followed by reinstall from ms store also worked.
>wsl --unregister ubuntufollowed by>wsl --installfixes the problem for ubuntu atleast
worked!
>wsl --unregister ubuntufollowed by>wsl --installfixes the problem for ubuntu atleast
worked. thx
I have the same problem how to solve?
I achieved after running the commands wsl --unregister ubuntu and wsl --instal
after uninstalling ubuntu from the microsoft store and installing again
in pws: wsl --unregister kali-linux
wsl --install kali-linux
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???
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???
If your vhdx file is missing, it might be that your data is already gone -- as that file has been deleted which is the storage volume for the Ubuntu operating system. Uninstalling and reinstalling just reinstates that fresh volume.
Facing this problem too, when trying to install wsl
Works (as of 11/09/2023): wsl --unregister ubuntu wsl -- install
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.
I've run into the same problem. Tried using Recuva to see if I could restore the file with no luck.
I wonder if this data loss is related to behaviours associated with these directories. From the UWP docs;
- Each UWP app gets several folders under
c:\users<user name>\AppData\Local\Packages<app package identifier>\, which appears to be the case for WSL distros as well. At least those distributed via the store. LocalStateis for data local to the current device. OneDrive backs up this data, such that it can be restored on new devices.- There is also
RoamingState(in Windows 11 it no longer roams) andTempState. Such backup behaviour should be readonly for the current device, so I do not know how it could cause this. I just know from the docs that it is a mechanism that touches this area and that something abnormal has occurred.
Possibly related issues;
- No cause determined - https://stackoverflow.com/questions/52713201/downloaded-files-in-appdata-local-packages-auto-deleting-in-uwp
- Certificate issue with side-loaded app - https://stackoverflow.com/questions/74595055/uwp-storage-file-is-deleted-on-close-even-though-i-did-not-how-can-i-prevent-it
I know on Android if the certificate used to sign an app changes, data-loss occurs. I believe the same applies to UWP/sandboxed apps on Windows. So in my case if the certificate for Ubuntu 22.04 changed with an app update, that may have wiped the data (possibly in a manner that leaves just enough behind that errors are raised rather than a new install being started).
Looking at the last modified date in MS Store, I can see "Ubuntu 22.04.2 LTS" was modified on 2023-09-03, which is between my last usage and discovery of this issue. Currently installed version is 2204.2.47.0.
Assuming the issue was caused by LocalState being wiped due to certificate changes, preventing reoccurrence means having the WSL files live somewhere else. The easiest way to achieve this would be;
- Install as normal.
- Open shell (not in installed distro, Windows Powershell is what I used)
- Export distro
wsl --export <distro-name> $env:UserProfile\Downloads\distro.tar - Delete distro
wsl --unregister <distro-name> - Import exported distro
wsl --import <distro-name> <install-location> $env:UserProfile\Downloads\distro.tar
Output is slightly different to what OP posted, so here it what I got (to aid future searches).
Failed to attach disk 'C:\Users\jorda\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu22.04LTS_79rhkp1fndgsc\LocalState\ext4.vhdx' to WSL2: The system cannot find the file specified.
Error code: Wsl/Service/CreateInstance/MountVhd/ERROR_FILE_NOT_FOUND
[process exited with code 4294967295 (0xffffffff)]
You can now close this terminal with Ctrl+D, or press Enter to restart.
i had to adapt the unix command so it was 'wsl unregister kali-linux' the ran the 2nd linux command and it worked perfectly thanx!
I've also had a similar problem, and trying @daniel-rodriguez-azumo's solution didn't work for me. In my case, wsl error after updating the user directory
what should I do? how to update the OldPath to CurrentPath on users directory?
Failed to attach disk 'C:\Users\OldPath\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState\ext4.vhdx' to WSL2: The system cannot find the path specified.
Error code: Wsl/Service/CreateInstance/MountVhd/ERROR_PATH_NOT_FOUND
// The old path
C:\Users\OldPath\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState\ext4.vhdx
// The right path:
C:\Users\CurrentPath\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState\ext4.vhdx
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.
Thanks this is working 👍 wsl --unregister ubuntu wsl -- install
had this today. Got lucky just reboot of Windows fixed it. (Microsoft Windows NT 10.0.22621.0)
>wsl --unregister ubuntufollowed by>wsl --installfixes the problem for ubuntu atleast
This is the one. Thank you!
>wsl --unregister ubuntuardından>wsl --installen azından ubuntu için sorun düzeltildi
it worked, thanks 👍