Azure Windows VM 关闭时停滞在“正在重启”、“正在关闭”或“正在停止服务”状态Azure Windows VM shutdown is stuck on "Restarting", "Shutting Down", or "Stopping services"

本文提供的步骤可解决在重新启动 Azure 中的 Windows 虚拟机 (VM) 时,可能遇到的“正在重启”、“正在关闭”或“正在停止服务”消息的问题。This article provides steps to resolve the issues of "Restarting", "Shutting down", or "Stopping services" messages that you may encounter when you reboot a Windows virtual machine (VM) in Azure.


使用启动诊断查看 VM 的屏幕截图时,可能会看到屏幕截图显示消息“正在重启”、“正在关闭”或“正在停止服务”。When you use Boot diagnostics to view the screenshot of the VM, you may see that the screenshot displays the message "Restarting", "Shutting down", or "Stopping services".



Windows 使用关闭进程来执行系统维护操作,并处理更新、角色和功能等方面的更改。Windows uses the shutdown process to perform system maintenance operations, and process changes such as updates, roles, and features. 建议不要中断此关键进程,而是让它完成。It's not recommended to interrupt this critical process until it completes. 根据更新/更改数量和 VM 大小,此进程可能会花费较长的时间。Depending on the number of updates/changes and the VM size, the process may take a long time. 如果停止该进程,OS 可能会损坏。If the process is stopped, it's possible for the OS to become corrupt. 仅当该进程耗时过长时才将其中断。Only interrupt the process if it's taking excessively long.


收集 OS 内存转储Collect an OS memory dump

需要收集内存转储文件并与支持人员联系。You would need to collect a memory dump file and contact support. 若要收集转储文件,请执行以下步骤:To collect the Dump file, follow these steps:

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

  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. 通过远程桌面连接到恢复 VM。Remote desktop to the recovery VM.

  4. 如果 OS 磁盘已加密,则必须先关闭加密,然后才能进入下一步。If the OS disk is encrypted, you must turn off the encryption before you move to the next step. 有关详细信息,请参阅在无法启动的 VM 中解密加密的 OS 磁盘For more information, see Decrypt the encrypted OS disk in the VM that cannot boot.

找到转储文件并提交支持票证Locate dump file and submit a support ticket

  1. 在恢复 VM 上,转到附加的 OS 磁盘中的 Windows 文件夹。On the recovery VM, go to windows folder in the attached OS disk. 如果分配给附加 OS 磁盘的驱动器号为 F,则需转到 F:\Windows。If the driver letter that is assigned to the attached OS disk is F, you need to go to F:\Windows.

  2. 找到 memory.dmp 文件,然后使用该转储文件提交支持票证Locate the memory.dmp file, and then submit a support ticket with the dump file.

如果找不到转储文件,请转到下一步以启用转储日志和串行控制台。If you cannot find the dump file, move the next step to enable dump log and Serial Console.

启用转储日志和串行控制台Enable dump log and Serial Console

若要启用转储日志和串行控制台,请运行以下脚本。To enable dump log and Serial Console, run the following script.

  1. 打开提升的命令提示符会话(以管理员身份运行)。Open elevated command Prompt session (Run as administrator).

  2. 运行以下脚本:Run the following script:

    在此脚本中,假定分配给附加 OS 磁盘的驱动器号为 F。将其替换为 VM 中的相应值。In this script, we assume that the drive letter that is assigned to the attached OS disk is F. Replace it with the appropriate value in your VM.

    reg load HKLM\BROKENSYSTEM F:\windows\system32\config\
    REM Enable Serial Console
    bcdedit /store F:\boot\bcd /set {bootmgr} displaybootmenu yes
    bcdedit /store F:\boot\bcd /set {bootmgr} timeout 5
    bcdedit /store F:\boot\bcd /set {bootmgr} bootems yes
    bcdedit /store F:\boot\bcd /ems {<BOOT LOADER IDENTIFIER>} ON
    bcdedit /store F:\boot\bcd /emssettings EMSPORT:1 EMSBAUDRATE:115200
    REM Suggested configuration to enable OS Dump
    REG ADD "HKLM\BROKENSYSTEM\ControlSet001\Control\CrashControl" /v CrashDumpEnabled /t REG_DWORD /d 1 /f
    REG ADD "HKLM\BROKENSYSTEM\ControlSet001\Control\CrashControl" /v DumpFile /t REG_EXPAND_SZ /d "%SystemRoot%\MEMORY.DMP" /f
    REG ADD "HKLM\BROKENSYSTEM\ControlSet001\Control\CrashControl" /v NMICrashDump /t REG_DWORD /d 1 /f
    REG ADD "HKLM\BROKENSYSTEM\ControlSet002\Control\CrashControl" /v CrashDumpEnabled /t REG_DWORD /d 1 /f
    REG ADD "HKLM\BROKENSYSTEM\ControlSet002\Control\CrashControl" /v DumpFile /t REG_EXPAND_SZ /d "%SystemRoot%\MEMORY.DMP" /f
    REG ADD "HKLM\BROKENSYSTEM\ControlSet002\Control\CrashControl" /v NMICrashDump / t REG_DWORD /d 1 /f
    reg unload HKLM\BROKENSYSTEM
  3. 确认磁盘上有足够的空间来分配与 RAM 一样多的内存,具体取决于为此 VM 选择的大小。Verify that there's enough space on the disk to allocate as much memory as the RAM, which depends on the size that you are selecting for this VM.

  4. 如果没有足够的空间或者 VM 较大(G、GS 或 E 系列),则可随后更改创建此文件时所在的位置,将该位置指向任何其他附加到 VM 的数据磁盘。If there's not enough space or the VM is large (G, GS or E series), you could change the location where this file will be created and refer that to any other data disk, which is attached to the VM. 若要更改位置,必须更改以下注册表项:To change the location, you must change the following key:

    reg load HKLM\BROKENSYSTEM F:\windows\system32\config\
    REG ADD "HKLM\BROKENSYSTEM\ControlSet001\Control\CrashControl" /v DumpFile /t REG_EXPAND_SZ /d "<DRIVE LETTER OF YOUR DATA DISK>:\MEMORY.DMP" /f
    REG ADD "HKLM\BROKENSYSTEM\ControlSet002\Control\CrashControl" /v DumpFile /t REG_EXPAND_SZ /d "<DRIVE LETTER OF YOUR DATA DISK>:\MEMORY.DMP" /f
    reg unload HKLM\BROKENSYSTEM
  5. 分离 OS 磁盘,然后将 OS 磁盘重新附加到受影响的 VMDetach the OS disk and then reattach the OS disk to the affected VM.

  6. 启动 VM 并访问串行控制台。Start the VM and access the Serial Console.

  7. 选择“发送不可屏蔽中断(NMI)”以触发内存转储。Select Send Non-Maskable Interrupt (NMI) to trigger the memory dump.


  8. 再次将 OS 磁盘附加到恢复 VM,收集转储文件。Attach the OS disk to a recovery VM again, collect dump file.

联系 Azure 支持部门Contact Azure support

收集转储文件后,请联系 Azure 支持人员来确定根本原因。After you collect the dump file, contact Azure support to determine the root cause.