Fixing the Issue of Ubuntu on WSL Failing to Boot After Reinstallation

After reinstalling Ubuntu on WSL, you might encounter an issue where Ubuntu fails to boot. You’ll see the following error in the console:

Failed to attach disk 'C:\Users\ahaya\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState\ext4.vhdx' to WSL2: The system cannot find the file specified.
Error code: Wsl/Service/CreateInstance/MountVhd/ERROR_FILE_NOT_FOUND
Failed to attach disk 'C:\Users\ahaya\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalState\ext4.vhdx' to WSL2: The system cannot find the file specified.
Error code: Wsl/Service/CreateInstance/MountVhd/ERROR_FILE_NOT_FOUND
Failed to attach disk 'C:\Users\ahaya\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\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...
目次

How to fix it

To fix this problem, you’ll need to carry out the initialization process. Ubuntu on WSL executes this process during its first boot. Unfortunately, this process gets skipped during a reinstallation of Ubuntu as some information remains in the system.

Please note that you will be deleting Ubuntu and your data will be lost.

Follow these steps to clear this residual information.

STEP
Press any key to quit if you see an error message.
STEP
Launch the Windows PowerShell.
STEP
Get the registered distributions.
PS C:\Users\Name> wsl -l
Windows Subsystem for Linux Distributions:
docker-desktop-data (Default)
docker-desktop
Ubuntu

In this example, three distributions are registered.

STEP
Unregister the Ubuntu distribution.

This operation will delete Ubuntu itself. Therefore, please note that the data will also be lost.

PS C:\Users\User> wsl --unregister Ubuntu
Unregistering.
The operation completed successfully.
STEP
Launch Ubuntu. This triggers the initialization process.

Ubuntu will now perform the initialization process as the previous registration information has been removed from your system. After completing the process, you can create a new account for Ubuntu.

Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username:

著書紹介

よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!

この記事を書いた人

Akira Hayashi (林 晃)のアバター Akira Hayashi (林 晃) Representative(代表), Software Engineer(ソフトウェアエンジニア)

アールケー開発代表。Appleプラットフォーム向けの開発を専門としているソフトウェアエンジニア。ソフトウェアの受託開発、技術書執筆、技術指導・セミナー講師。note, Medium, LinkedIn
-
Representative of RK Kaihatsu. Software Engineer Specializing in Development for the Apple Platform. Specializing in contract software development, technical writing, and serving as a tech workshop lecturer. note, Medium, LinkedIn

目次