Azure VM 启动在更新 Windows 时停滞Azure VM startup is stuck at Windows update

本文可帮助你解决虚拟机 (VM) 在启动过程中停滞在 Windows 更新阶段的问题。This article helps resolve the issue when your Virtual Machine (VM) is stuck at the Windows Update stage during startup.

Note

Azure 具有用于创建和处理资源的两个不同的部署模型:资源管理器部署模型和经典部署模型Azure has two different deployment models for creating and working with resources: Resource Manager and classic. 本文介绍如何使用 Resource Manager 部署模型。This article covers using the Resource Manager deployment model. 建议为新部署使用此模型,而不是使用经典部署模型。We recommend that you use this model for new deployments instead of using the classic deployment model.

症状Symptom

Windows VM 不启动。A Windows VM doesn't start. 检查启动诊断窗口中的屏幕截图时,看到启动停滞在更新进程。When you check the screenshots in the Boot diagnostics window, you see that the startup is stuck in the update process. 下面是可能收到的消息示例:The following are examples of messages that you may receive:

  • 正在安装 Windows ##% 请不要关闭电脑。Installing Windows ##% Don't turn off your PC. 你的电脑将重启几次 这可能需要一点时间This will take a while Your PC will restart several times
  • 使电脑保持开机状态 直到操作完成。Keep your PC on until this is done. 正在安装第 # 个更新 共 # 个...Installing update # of #...
  • 无法完成更新 正在撤销更改 请不要关闭计算机We couldn't complete the updates Undoing changes Don't turn off your computer
  • 配置 Windows 更新失败 正在还原更改 请不要关闭计算机Failure configuring Windows updates Reverting changes Do not turn off your computer
  • 应用第 #### 个(共 #### 个)更新操作时出错 <错误代码> (\Regist...)Error < error code > applying update operations ##### of ##### (\Regist...)
  • 应用第 #### 个(共 #### 个)更新操作时出现灾难性错误 <错误代码> ($$...)Fatal Error < error code > applying update operations ##### of ##### ($$...)

解决方案Solution

根据要安装或回退的更新数量,更新过程可能需要一段时间。Depending on the number of updates that are getting installed or rolled backing, the update process can take a while. 将 VM 保持这种状态 8 小时。Leave the VM in this state for 8 hours. 如果该时间段后 VM 仍处于此状态,请从 Azure 门户中重启 VM,然后查看是否可以正常启动。If the VM is still in this state after that period, restart the VM from the Azure portal, and see if it can start normally. 如果此步骤不起作用,请尝试以下解决方案。If this step doesn't work, try the following solution.

删除导致问题的更新Remove the update that causes the problem

  1. 拍摄受影响的 VM 的 OS 磁盘的快照作为备份。Take a snapshot of the OS disk of the affected VM as a backup. 有关详细信息,请参阅拍摄磁盘快照For more information, see Snapshot a disk.

  2. 将 OS 磁盘附加到恢复 VMAttach the OS disk to a recovery VM.

  3. 将 OS 磁盘附加到恢复 VM 上后,运行 diskmgmt.msc 以打开磁盘管理,并确保所附磁盘已联机Once the OS disk is attached on the recovery VM, run diskmgmt.msc to open Disk Management, and ensure the attached disk is ONLINE. 记下分配给保存 \windows 文件夹的附加 OS 磁盘的驱动器号。Take note of the drive letter that is assigned to the attached OS disk holding the \windows folder. 如果磁盘已加密,先解密磁盘,然后再继续此文档中的下一步。If the disk is encrypted, decrypt the disk before proceeding with next steps in this document.

  4. 打开权限提升的命令提示符实例(“以管理员身份运行”)。Open an elevated command prompt instance (Run as administrator). 运行以下命令获取附加 OS 磁盘上的更新包列表:Run the following command to get the list of the update packages that are on the attached OS disk:

     dism /image:<Attached OS disk>:\ /get-packages > c:\temp\Patch_level.txt
    

    例如,如果附加 OS 磁盘是驱动器 F,则运行以下命令:For example, if the attached OS disk is drive F, run the following command:

     dism /image:F:\ /get-packages > c:\temp\Patch_level.txt
    
  5. 打开 C:\temp\Patch_level.txt 文件,然后从下往上浏览。Open the C:\temp\Patch_level.txt file, and then read it from the bottom up. 查找处于“安装挂起”或“卸载挂起”状态的更新 。Locate the update that's in Install Pending or Uninstall Pending state. 以下是更新状态的示例:The following is a sample of the update status:

    Package Identity : Package_for_RollupFix~31bf3856ad364e35~amd64~~17134.345.1.5
    State : Install Pending
    Release Type : Security Update
    Install Time :
    
  6. 删除导致问题的更新:Remove the update that caused the problem:

    dism /Image:<Attached OS disk>:\ /Remove-Package /PackageName:<PACKAGE NAME TO DELETE>
    

    示例:Example:

    dism /Image:F:\ /Remove-Package /PackageName:Package_for_RollupFix~31bf3856ad364e35~amd64~~17134.345.1.5
    

    Note

    DISM 工具需要一些时间来处理取消安装,具体取决于包的大小。Depending on the size of the package, the DISM tool will take a while to process the un-installation. 通常情况下,该过程在 16 分钟内完成。Normally the process will be completed within 16 minutes.

  7. 分离 OS 磁盘并重新创建 VMDetach the OS disk and recreate the VM. 然后检查是否解决了问题。Then check whether the issue is resolved.