Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File missing after command "wsl --update" showing "WSL is finishing an ugrade... Update failed (exit code:1603) Error code:Wsl/CallMsi/E_ABORT" #10651

Closed
ChenLiangYin opened this issue Oct 20, 2023 · 16 comments

Comments

@ChenLiangYin
Copy link

ChenLiangYin commented Oct 20, 2023

Today I want to check the volume of my virtual machine. Therefore, I just want to update my wsl. However, it shows the message "WSL is finishing an ugrade... Update failed (exit code:1603) Error code:Wsl/CallMsi/E_ABORT" which seems unable to update. However, after that, my virtual machine and all of my files on it were gone. I am using the Ubuntu 20.04

@OneBlue
Copy link
Collaborator

OneBlue commented Oct 20, 2023

Thank you for reporting this @ChenLiangYin. Which version of WSL are you running ? What's the output of wsl --version ?

@ChenLiangYin
Copy link
Author

ChenLiangYin commented Oct 20, 2023

Thank you for your reply!
In fact I am looking for some solutions in
https://answers.microsoft.com/en-us/windows/forum/all/wsl-files-missing-after-windows-11-update/a13c4a14-f67e-488b-8259-0340a7cf503e and I uninstalled the app I just installed (windows subsystem for linux). And the linux distribution has come back. However, if I open the vscode with wsl. It fails to connect to the wsl.

I think I am in wsl2. "wsl --version" shows "invalid command line option --version".
I still remember I have two wsl.exe in the past when checking "where wsl". The wsl under system32 is 10.0.22621.2483

@OneBlue
Copy link
Collaborator

OneBlue commented Oct 20, 2023

It looks like you reverted to inbox wsl. Can you try to run wsl --update and see if that solves the issue ?

@OneBlue
Copy link
Collaborator

OneBlue commented Oct 20, 2023

If you install WSL > 2.0 again, can you collect logs during the installation so we can see where the issue is ?

/logs

@ChenLiangYin
Copy link
Author

#Requires -RunAsAdministrator

[CmdletBinding()]
Param (
$LogProfile = $null,
[switch]$Dump = $false
)

Set-StrictMode -Version Latest

$folder = "WslLogs-" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss")
mkdir -p $folder

if ($LogProfile -eq $null)
{
$LogProfile = "$folder/wsl.wprp"
try {
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp" -OutFile $LogProfile
}
catch {
throw
}
}

reg.exe export HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss $folder/HKCU.txt
reg.exe export HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Lxss $folder/HKLM.txt
reg.exe export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\P9NP $folder/P9NP.txt
reg.exe export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2 $folder/Winsock2.txt

$wslconfig = "$env:USERPROFILE/.wslconfig"
if (Test-Path $wslconfig)
{
Copy-Item $wslconfig $folder
}

get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux > $folder/appxpackage.txt
get-acl "C:\ProgramData\Microsoft\Windows\WindowsApps" -ErrorAction Ignore | Format-List > $folder/acl.txt
Get-WindowsOptionalFeature -Online > $folder/optional-components.txt
bcdedit.exe > $folder/bcdedit.txt

$wprOutputLog = "$folder/wpr.txt"

wpr.exe -start $LogProfile -filemode 2>&1 >> $wprOutputLog
if ($LastExitCode -Ne 0)
{
Write-Host -ForegroundColor Yellow "Log collection failed to start (exit code: $LastExitCode), trying to reset it."
wpr.exe -cancel 2>&1 >> $wprOutputLog

wpr.exe -start $LogProfile -filemode 2>&1 >> $wprOutputLog
if ($LastExitCode -Ne 0)
{
    Write-Host -ForegroundColor Red "Couldn't start log collection (exitCode: $LastExitCode)"
}

}

try
{
Write-Host -NoNewLine -ForegroundColor Green "Log collection is running. Please reproduce the problem and press any key to save the logs."

$KeysToIgnore =
      16,  # Shift (left or right)
      17,  # Ctrl (left or right)
      18,  # Alt (left or right)
      20,  # Caps lock
      91,  # Windows key (left)
      92,  # Windows key (right)
      93,  # Menu key
      144, # Num lock
      145, # Scroll lock
      166, # Back
      167, # Forward
      168, # Refresh
      169, # Stop
      170, # Search
      171, # Favorites
      172, # Start/Home
      173, # Mute
      174, # Volume Down
      175, # Volume Up
      176, # Next Track
      177, # Previous Track
      178, # Stop Media
      179, # Play
      180, # Mail
      181, # Select Media
      182, # Application 1
      183  # Application 2

$Key = $null
while ($Key -Eq $null -Or $Key.VirtualKeyCode -Eq $null -Or $KeysToIgnore -Contains $Key.VirtualKeyCode)
{
    $Key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
}

Write-Host "`nSaving logs..."

}
finally
{
wpr.exe -stop $folder/logs.etl 2>&1 >> $wprOutputLog
}

if ($Dump)
{
$Assembly = [PSObject].Assembly.GetType('System.Management.Automation.WindowsErrorReporting')
$DumpMethod = $Assembly.GetNestedType('NativeMethods', 'NonPublic').GetMethod('MiniDumpWriteDump', [Reflection.BindingFlags] 'NonPublic, Static')

$dumpFolder = Join-Path (Resolve-Path "$folder") dumps
New-Item -ItemType "directory" -Path "$dumpFolder"

$executables = "wsl", "wslservice", "wslhost", "msrdc"
foreach($process in Get-Process | Where-Object { $executables -contains $_.ProcessName})
{
    $dumpFile =  "$dumpFolder/$($process.ProcessName).$($process.Id).dmp"
    Write-Host "Writing $($dumpFile)"

    $OutputFile = New-Object IO.FileStream($dumpFile, [IO.FileMode]::Create)

    $Result = $DumpMethod.Invoke($null, @($process.Handle,
                                          $process.id,
                                          $OutputFile.SafeFileHandle,
                                          [UInt32] 2,
                                          [IntPtr]::Zero,
                                          [IntPtr]::Zero,
                                          [IntPtr]::Zero))

    $OutputFile.Close()
    if (-not $Result)
    {
        Write-Host "Failed to write dump for: $($dumpFile)"
    }
}

}

Collect networking state relevant for WSL

Using a try/catch for commands below, as some of them do not exist on all OS versions

Write-Host "`nCollecting additional network state..."

$networkingFolder = "$folder/networking"
mkdir -p $networkingFolder

Host networking info

try
{
Get-NetAdapter -includeHidden | select Name,ifIndex,NetLuid,InterfaceGuid,Status,MacAddress,MtuSize,InterfaceType,Hidden,HardwareInterface,ConnectorPresent,MediaType,PhysicalMediaType | Out-File -FilePath "$networkingFolder/Get-NetAdapter.log" -Append
}
catch {}

try
{
Get-NetIPConfiguration -All -Detailed | Out-File -FilePath "$networkingFolder/Get-NetIPConfiguration.log" -Append
}
catch {}

try
{
Get-NetFirewallHyperVVMCreator | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVVMCreator.log" -Append
}
catch {}

try
{
Get-NetFirewallHyperVVMSetting -PolicyStore ActiveStore | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVVMSetting_ActiveStore.log" -Append
}
catch {}

try
{
Get-NetFirewallHyperVProfile -PolicyStore ActiveStore | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVProfile_ActiveStore.log" -Append
}
catch {}

try
{
Get-NetFirewallHyperVPort | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVPort.log" -Append
}
catch {}

try
{
& hnsdiag.exe list all 2>&1 > $networkingFolder/hnsdiag_list_all.log
}
catch {}

try
{
& hnsdiag.exe list endpoints -df 2>&1 > $networkingFolder/hnsdiag_list_endpoints.log
}
catch {}

try
{
foreach ($port in Get-NetFirewallHyperVPort)
{
& vfpctrl.exe /port $port.PortName /get-port-state 2>&1 > "$networkingFolder/vfp-port-$($port.PortName)-get-port-state.log"
& vfpctrl.exe /port $port.PortName /list-rule 2>&1 > "$networkingFolder/vfp-port-$($port.PortName)-list-rule.log"
}
}
catch {}

try
{
& vfpctrl.exe /list-vmswitch-port 2>&1 > $networkingFolder/vfpctrl_list_vmswitch_port.log
}
catch {}

$logArchive = "$(Resolve-Path $folder).zip"
Compress-Archive -Path $folder -DestinationPath $logArchive
Remove-Item $folder -Recurse

Write-Host -ForegroundColor Green "Logs saved in: $logArchive. Please attach that file to the GitHub issue."

@ChenLiangYin
Copy link
Author

Actually I have found the the ubuntu folder in %localappdata% where the ext4 still exists. It seems like those files are still intact. However, I don't know why after uninstalling the apps I still couldn't connect wsl.

@ChenLiangYin
Copy link
Author

ChenLiangYin commented Oct 20, 2023

It looks like you reverted to inbox wsl. Can you try to run wsl --update and see if that solves the issue ?

No, the problem still exists even if I push the repair button. If there anyway to repair and restore my original wsl? or I have to shutdown the original one and create a new one with the original ext4. I just copied it to other disk.

@OneBlue
Copy link
Collaborator

OneBlue commented Oct 20, 2023

Does manually installing the latest release solve the issue ?

@ChenLiangYin
Copy link
Author

ChenLiangYin commented Oct 20, 2023

I am installing it manually. But it shows "WSL service could not be installed. Verify you have sufficient privileges to install system services". But I am administer...

@OneBlue
Copy link
Collaborator

OneBlue commented Oct 20, 2023

Can you collect logs during the install ?

/logs

@ChenLiangYin
Copy link
Author

#Requires -RunAsAdministrator

[CmdletBinding()]
Param (
$LogProfile = $null,
[switch]$Dump = $false
)

Set-StrictMode -Version Latest

$folder = "WslLogs-" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss")
mkdir -p $folder

if ($LogProfile -eq $null)
{
$LogProfile = "$folder/wsl.wprp"
try {
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp" -OutFile $LogProfile
}
catch {
throw
}
}

reg.exe export HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss $folder/HKCU.txt
reg.exe export HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Lxss $folder/HKLM.txt
reg.exe export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\P9NP $folder/P9NP.txt
reg.exe export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2 $folder/Winsock2.txt

$wslconfig = "$env:USERPROFILE/.wslconfig"
if (Test-Path $wslconfig)
{
Copy-Item $wslconfig $folder
}

get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux > $folder/appxpackage.txt
get-acl "C:\ProgramData\Microsoft\Windows\WindowsApps" -ErrorAction Ignore | Format-List > $folder/acl.txt
Get-WindowsOptionalFeature -Online > $folder/optional-components.txt
bcdedit.exe > $folder/bcdedit.txt

$wprOutputLog = "$folder/wpr.txt"

wpr.exe -start $LogProfile -filemode 2>&1 >> $wprOutputLog
if ($LastExitCode -Ne 0)
{
Write-Host -ForegroundColor Yellow "Log collection failed to start (exit code: $LastExitCode), trying to reset it."
wpr.exe -cancel 2>&1 >> $wprOutputLog

wpr.exe -start $LogProfile -filemode 2>&1 >> $wprOutputLog
if ($LastExitCode -Ne 0)
{
    Write-Host -ForegroundColor Red "Couldn't start log collection (exitCode: $LastExitCode)"
}

}

try
{
Write-Host -NoNewLine -ForegroundColor Green "Log collection is running. Please reproduce the problem and press any key to save the logs."

$KeysToIgnore =
      16,  # Shift (left or right)
      17,  # Ctrl (left or right)
      18,  # Alt (left or right)
      20,  # Caps lock
      91,  # Windows key (left)
      92,  # Windows key (right)
      93,  # Menu key
      144, # Num lock
      145, # Scroll lock
      166, # Back
      167, # Forward
      168, # Refresh
      169, # Stop
      170, # Search
      171, # Favorites
      172, # Start/Home
      173, # Mute
      174, # Volume Down
      175, # Volume Up
      176, # Next Track
      177, # Previous Track
      178, # Stop Media
      179, # Play
      180, # Mail
      181, # Select Media
      182, # Application 1
      183  # Application 2

$Key = $null
while ($Key -Eq $null -Or $Key.VirtualKeyCode -Eq $null -Or $KeysToIgnore -Contains $Key.VirtualKeyCode)
{
    $Key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
}

Write-Host "`nSaving logs..."

}
finally
{
wpr.exe -stop $folder/logs.etl 2>&1 >> $wprOutputLog
}

if ($Dump)
{
$Assembly = [PSObject].Assembly.GetType('System.Management.Automation.WindowsErrorReporting')
$DumpMethod = $Assembly.GetNestedType('NativeMethods', 'NonPublic').GetMethod('MiniDumpWriteDump', [Reflection.BindingFlags] 'NonPublic, Static')

$dumpFolder = Join-Path (Resolve-Path "$folder") dumps
New-Item -ItemType "directory" -Path "$dumpFolder"

$executables = "wsl", "wslservice", "wslhost", "msrdc"
foreach($process in Get-Process | Where-Object { $executables -contains $_.ProcessName})
{
    $dumpFile =  "$dumpFolder/$($process.ProcessName).$($process.Id).dmp"
    Write-Host "Writing $($dumpFile)"

    $OutputFile = New-Object IO.FileStream($dumpFile, [IO.FileMode]::Create)

    $Result = $DumpMethod.Invoke($null, @($process.Handle,
                                          $process.id,
                                          $OutputFile.SafeFileHandle,
                                          [UInt32] 2,
                                          [IntPtr]::Zero,
                                          [IntPtr]::Zero,
                                          [IntPtr]::Zero))

    $OutputFile.Close()
    if (-not $Result)
    {
        Write-Host "Failed to write dump for: $($dumpFile)"
    }
}

}

Collect networking state relevant for WSL

Using a try/catch for commands below, as some of them do not exist on all OS versions

Write-Host "`nCollecting additional network state..."

$networkingFolder = "$folder/networking"
mkdir -p $networkingFolder

Host networking info

try
{
Get-NetAdapter -includeHidden | select Name,ifIndex,NetLuid,InterfaceGuid,Status,MacAddress,MtuSize,InterfaceType,Hidden,HardwareInterface,ConnectorPresent,MediaType,PhysicalMediaType | Out-File -FilePath "$networkingFolder/Get-NetAdapter.log" -Append
}
catch {}

try
{
Get-NetIPConfiguration -All -Detailed | Out-File -FilePath "$networkingFolder/Get-NetIPConfiguration.log" -Append
}
catch {}

try
{
Get-NetFirewallHyperVVMCreator | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVVMCreator.log" -Append
}
catch {}

try
{
Get-NetFirewallHyperVVMSetting -PolicyStore ActiveStore | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVVMSetting_ActiveStore.log" -Append
}
catch {}

try
{
Get-NetFirewallHyperVProfile -PolicyStore ActiveStore | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVProfile_ActiveStore.log" -Append
}
catch {}

try
{
Get-NetFirewallHyperVPort | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVPort.log" -Append
}
catch {}

try
{
& hnsdiag.exe list all 2>&1 > $networkingFolder/hnsdiag_list_all.log
}
catch {}

try
{
& hnsdiag.exe list endpoints -df 2>&1 > $networkingFolder/hnsdiag_list_endpoints.log
}
catch {}

try
{
foreach ($port in Get-NetFirewallHyperVPort)
{
& vfpctrl.exe /port $port.PortName /get-port-state 2>&1 > "$networkingFolder/vfp-port-$($port.PortName)-get-port-state.log"
& vfpctrl.exe /port $port.PortName /list-rule 2>&1 > "$networkingFolder/vfp-port-$($port.PortName)-list-rule.log"
}
}
catch {}

try
{
& vfpctrl.exe /list-vmswitch-port 2>&1 > $networkingFolder/vfpctrl_list_vmswitch_port.log
}
catch {}

$logArchive = "$(Resolve-Path $folder).zip"
Compress-Archive -Path $folder -DestinationPath $logArchive
Remove-Item $folder -Recurse

Write-Host -ForegroundColor Green "Logs saved in: $logArchive. Please attach that file to the GitHub issue."

@OneBlue
Copy link
Collaborator

OneBlue commented Oct 20, 2023

You need to run the script and upload the file it produces, this is just the content of the script.

/logs

@ChenLiangYin
Copy link
Author

@ChenLiangYin
Copy link
Author

ChenLiangYin commented Oct 20, 2023

Sorry I see.
This is another previous log file I have when installing wsl
WslLogs-2023-10-21_03-17-06.zip

@ChenLiangYin
Copy link
Author

ChenLiangYin commented Oct 21, 2023

You need to run the script and upload the file it produces, this is just the content of the script.

/logs

I found out the solution now. I install a new distribution Ubuntu-22.04 now and replace its ext4 file with my previous one (on ubuntu20.04) and it works! All the files and data got restored. And I can open it on vscode. However, I am not sure if there is any problem when doing this way.

Now I feel like I should store the files on my mnt/ not on the virtual machine.

@benhillis
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants