Windows VM 因 Windows 启动管理器而无法启动Windows VM cannot boot due to Windows Boot Manager

本文提供了相关步骤,用于解决 Windows 启动管理器阻止 Azure 虚拟机 (VM) 启动的问题。This article provides steps to resolve issues where Windows Boot Manager prevents the booting of an Azure Virtual Machine (VM).

症状Symptom

VM 一直在等待用户提示。除非用户手动进行指示,否则 VM 不会启动。The VM is stuck waiting upon a user prompt and doesn't boot unless manually instructed to.

使用启动诊断查看 VM 的屏幕截图时,会看到屏幕截图显示 Windows 启动管理器,其中包含消息“请选择要启动的操作系统,或按 TAB 键选择一项工具:” 。When you use Boot diagnostics to view the screenshot of the VM, you'll see that the screenshot displays the Windows Boot Manager with the message Choose an operating system to start, or press TAB to select a tool: .

图 1Figure 1

Windows 启动管理器,其中包含消息“请选择要启动的操作系统,或按 TAB 键选择一项工具:”

原因Cause

此错误是由 Windows 启动管理器中的 BCD 标志“displaybootmenu” 导致的。The error is due to a BCD flag displaybootmenu in the Windows Boot Manager. 启用该标志后,Windows 启动管理器会在启动过程中提示用户选择要运行的加载程序,导致启动延迟。When the flag is enabled, Windows Boot Manager prompts the user, during the booting process, to select which loader they wish to run, causing a boot delay. 在 Azure 中,此功能可能会增加启动 VM 所需的时间。In Azure, this feature can add to the time it takes to boot a VM.

解决方案Solution

过程概述:Process Overview:

  1. 创建并访问修复 VM。Create and Access a Repair VM.
  2. 在修复 VM 上进行配置以缩短启动时间。Configure for Faster Boot Time on a Repair VM.
  3. 建议 :在重建 VM 之前,启用串行控制台和内存转储收集。Recommended : Before you rebuild the VM, enable serial console and memory dump collection.
  4. 重建 VM。Rebuild the VM.

创建并访问一个修复 VMCreate and Access a Repair VM

  1. 使用 VM 修复命令的步骤 1-3 来准备一个修复 VM。Use steps 1-3 of the VM Repair Commands to prepare a Repair VM.
  2. 使用远程桌面连接来连接到修复 VM。Use Remote Desktop Connection connect to the Repair VM.

在修复 VM 上进行配置以缩短启动时间。Configure for Faster Boot Time on a Repair VM

  1. 打开权限提升的命令提示符。Open an elevated command prompt.

  2. 输入以下命令来启用 DisplayBootMenu:Enter the following to enable DisplayBootMenu:

    对于第 1 代 VM ,请使用以下命令:Use this command for Generation 1 VMs :

    bcdedit /store <VOLUME LETTER WHERE THE BCD FOLDER IS>:\boot\bcd /set {bootmgr} displaybootmenu yes

    对于第 2 代 VM ,请使用以下命令:Use this command for Generation 2 VMs :

    bcdedit /store <VOLUME LETTER OF EFI SYSTEM PARTITION>:EFI\Microsoft\boot\bcd /set {bootmgr} displaybootmenu yes

    替换所有大于号或小于号以及其中的文本,例如“< text here >”。Replace any greater than or less than symbols as well as the text within them, e.g. "< text here >".

  3. 将超时值更改为 5 秒:Change the timeout value to 5 seconds:

    对于第 1 代 VM ,请使用以下命令:Use this command for Generation 1 VMs :

    bcdedit /store <VOLUME LETTER WHERE THE BCD FOLDER IS>:\boot\bcd /set {bootmgr} timeout 5

    对于第 2 代 VM ,请使用以下命令:Use this command for Generation 2 VMs :

    bcdedit /store <VOLUME LETTER OF EFI SYSTEM PARTITION>:EFI\Microsoft\boot\bcd /set {bootmgr} timeout 5

    替换所有大于号或小于号以及其中的文本,例如“< text here >”。Replace any greater than or less than symbols as well as the text within them, e.g. "< text here >".

若要启用内存转储收集和串行控制台,请运行以下脚本:To enable memory dump collection and Serial Console, run the following script:

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

  2. 运行以下命令:Run the following commands:

    启用串行控制台Enable Serial Console

    bcdedit /store <VOLUME LETTER WHERE THE BCD FOLDER IS>:\boot\bcd /ems {<BOOT LOADER IDENTIFIER>} ON

    bcdedit /store <VOLUME LETTER WHERE THE BCD FOLDER IS>:\boot\bcd /emssettings EMSPORT:1 EMSBAUDRATE:115200

    替换所有大于号或小于号以及其中的文本,例如“< text here >”。Replace any greater than or less than symbols as well as the text within them, e.g. "< text here >".

  3. 验证 OS 磁盘上的可用空间是否与 VM 上的内存大小 (RAM) 相当。Verify that the free space on the OS disk is as much as the memory size (RAM) on the VM.

    如果 OS 磁盘上没有足够的空间,则应更改内存转储文件的创建位置,并将该位置指向 VM 上附加的具有足够可用空间的任何数据磁盘。If there's not enough space on the OS disk, you should change the location where the memory dump file will be created and refer that to any data disk attached to the VM that has enough free space. 若要更改位置,请将以下命令中的“%SystemRoot%”替换为数据磁盘的驱动器号(例如“F:”)。To change the location, replace "%SystemRoot%" with the drive letter (for example, "F:") of the data disk in the below commands.

用于启用 OS 转储的建议配置Suggested configuration to enable OS Dump

加载损坏的 OS 磁盘:Load Broken OS Disk :

REG LOAD HKLM\BROKENSYSTEM <VOLUME LETTER OF BROKEN OS DISK>:\windows\system32\config\SYSTEM

在 ControlSet001 上启用:Enable on ControlSet001:

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

在 ControlSet002 上启用:Enable on ControlSet002:

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

卸载损坏的 OS 磁盘:Unload Broken OS Disk:

REG UNLOAD HKLM\BROKENSYSTEM

重建原始 VMRebuild the Original VM

使用 VM 修复命令的步骤 5 重新装配 VM。Use step 5 of the VM Repair Commands to reassemble the VM.