microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.02k stars 798 forks source link

`wsl --install -d Debian` fails `Error Code: 0x80070520` #10179

Closed Athanasius closed 1 year ago

Athanasius commented 1 year ago

Windows Version

Microsoft Windows 11 Pro [22621.1702]

WSL Version

1.2.5.0

Are you using WSL 1 or WSL 2?

Kernel Version

No response

Distro Version

Debian

Other Software

No response

Repro Steps

Trying out the Windows Store preview as per https://devblogs.microsoft.com/commandline/a-preview-of-wsl-in-the-microsoft-store-is-now-available/#:~:text=There%20are%20two%20big%20reasons%20to,when%20getting%20the%20latest%20WSL%20updates.&text=There%20are%20two%20big,the%20latest%20WSL%20updates.&text=two%20big%20reasons%20to,when%20getting%20the%20latest

  1. Installed WSL from the Windows Store.
  2. Ran the dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all command.
  3. Rebooted for that to take effect.
  4. Ran into https://github.com/microsoft/WSL/issues/9521
  5. Toggled "Windows Subsystem for Linux" on in "Windows Features".
  6. Rebooted for that to take effect.
  7. Login as my non-Admin/Limited user.
  8. Run a Powershell as Administrator (UAC prompt, password)
  9. wsl --list --online, which includes a line Debian Debian GNU/Linux
  10. wsl --install --distribution Debian results in:
    PS C:\WINDOWS\system32> wsl --install --distribution Debian
    Installing: Debian GNU/Linux
    An error occurred during installation. Distribution Name: 'Debian GNU/Linux' Error Code: 0x80070520
    PS C:\WINDOWS\system32>

Expected Behavior

Debian distribution should be installed.

Actual Behavior

The cited error.

Diagnostic Logs

No response

Athanasius commented 1 year ago

After another reboot I tried this by actually logging in as an Admin account and running PowerShell, and the command worked.

So, WSL requires the current Windows session to be an Admin user ? You can't just "Run as Administrator" ?

Oh, it's also working as my non-Admin user without running PowerShell as Administrator. So this:

Open PowerShell or Windows Command Prompt in administrator mode by right-clicking and selecting "Run as administrator", enter the wsl --install command, then restart your machine.

from https://learn.microsoft.com/en-gb/windows/wsl/install is at best misleading, and probably just plain wrong, at least for this Windows Store version of WSL ?

OneBlue commented 1 year ago

Thank you for reporting this @Athanasius. I wonder if this a store issue. Can you try installing via:

wsl --install -d debian --web-download

?

Athanasius commented 1 year ago

Thank you for reporting this @Athanasius. I wonder if this a store issue. Can you try installing via:

wsl --install -d debian --web-download

Right now it will succeed even without --web-download because the system already has the distribution. Checking wsl --help there only seems to be wsl --unregister <Distribution> (as per --list), but after that even wsl --install -d Debian quickly succeeds, presumably because the download has been cached.

Some websearching later I find https://petri.com/how-to-uninstall-and-reset-windows-subsystem-for-linux-distributions/ and remove 'Debian' from "Apps > Installed apps", and now:

PS C:\WINDOWS\system32> wsl --install -d Debian
Debian GNU/Linux is already installed.
Launching Debian GNU/Linux...
Failed to attach disk 'C:\Users\Athan\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\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...

So, that's only gotten it into an even worse state.

How do I make WSL actually forget about the distribution so I can even test if --web-download would have worked ?

Athanasius commented 1 year ago

Having gone through even more of a dance now.

  1. Completely removed the path under Packages for 'TheDebianProject'.
  2. wsl --unregister Debian as Limited user (all the last comment was under PowerShell > Run as Administrator).

This now appears to work. So, either something has been fixed in the meantime... or it's just a consequence of this now not being a WSL clean system, with something left behind allowing it to work.

I don't have the time or resources to re-test this from scratch now.

csmwww commented 1 month ago

PS C:\Windows\system32> wsl --status Default Version: 2

Windows Subsystem for Linux was last updated on 5/2/2024 The Windows Subsystem for Linux kernel can be manually updated with 'wsl --update', but automatic updates cannot occur due to your system settings. To receive automatic kernel updates, please enable the Windows Update setting: 'Receive updates for other Microsoft products when you update Windows'. For more information please visit https://aka.ms/wsl2kernel.

Kernel version: 5.10.16 PS C:\Windows\system32> wsl --install -d ubuntu Installing: Ubuntu An error occurred during installation. Distribution Name: 'Ubuntu' Error Code: 0x80070520 PS C:\Windows\system32> wsl --install -d ubuntu --web-download --install: unrecognized option: web-download

alex-aperia commented 5 days ago

I get exactly same error when trying to install Ubuntu. Any updates on this topic ?