共用方式為


針對 Azure Linux 虛擬機中的 UEFI 開機失敗進行疑難解答

注意事項

本文中參考的 CentOS 是 Linux 發行版,並會到達生命周期結束 (EOL) 。 請考慮您的使用並據以規劃。 如需詳細資訊,請 參閱 CentOS 生命週期結束指引

Azure Marketplace 中的 Linux 合作夥伴映射會針對第 1 代 BIOS 開機和整合可擴展固件介面 (UEFI) 第 2 代開機進行標記和設定。

當您在 Azure 中將第 2 代 Linux 虛擬機部署 (VM) 時,您可能會遇到 UEFI 開機失敗。 本文討論發生 UEFI 開機失敗的一些案例,並提供解決方案。

徵狀

當您在 Azure 中部署第 2 代 Linux VM 時,開機會失敗,且無法存取伺服器。

識別 UEFI 開機錯誤

使用 Azure 開機診斷來檢查 VM 的目前狀態。

開機診斷螢幕快照顯示下列錯誤訊息:

  • 錯誤 1

    虛擬機開機摘要

    1. 未知的裝置
      開機載入器未載入作業系統。
    2. SCSI 磁碟 (0,0)
      開機載入器未載入作業系統。
    3. SCSI 磁碟 (0,1)
      開機載入器未載入作業系統。
    4. 網路適配器 (000D3A4DD64D)
      找不到開機映像。

    未載入任何作業系統。 您的虛擬機設定可能不正確。 結束並重新設定您的 VM,或按兩下 [重新啟動] 再次重試目前的開機順序。

    遺失 UEFI 開機映射的 Hyper-V 錯誤訊息螢幕快照。

  • 錯誤 2

    透過 IPv4 啟動 PXE

    Hyper-V 錯誤轉換為 PXE 開機問題的螢幕快照。

進行疑難解答之前

若要執行案例 1 所需的離線 VM 修復:開機映射中的 UEFI 磁碟分區遺失,且開機映像中的案例 2:UEFI 磁碟分區已損毀,請確定您可以存取 Azure CLI 或 Azure Cloud Shell

案例 1:開機映射中的 UEFI 磁碟分區遺失

如果遺失或刪除 UEFI 開機載入器磁碟分區,第 2 代 Linux VM 將無法開機。

若要解決此問題,請遵循下列步驟:

  1. 使用 az vm repair create 命令來建立修復 VM。 修復 VM 會有一份作業系統磁碟復本,用於連接的非功能性 VM。 如需詳細資訊,請參閱 使用 Azure 虛擬機修復命令修復 Linux VM

  2. 使用下列命令重新建立資料分割:

    root@repair-centos7:~# gdisk /dev/sdc
    GPT fdisk (gdisk) version 1.0.3
    
    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present
    
    Found valid GPT with protective MBR; using GPT.
    
    Command (? for help): p
    Disk /dev/sdc: 134217728 sectors, 64.0 GiB
    Model: Virtual Disk    
    Sector size (logical/physical): 512/4096 bytes
    Disk identifier (GUID): <Disk GUID>
    Partition table holds up to 128 entries
    Main partition table begins at sector 2 and ends at sector 33
    First usable sector is 34, last usable sector is 134217694
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 1019837 sectors (498.0 MiB)
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       1         1026048         3123199   1024.0 MiB  0700  
       2         3123200       134215679   62.5 GiB    8E00  
      14            2048           10239   4.0 MiB     EF02  
    
    Command (? for help): n
    Partition number (3-128, default 3): 
    First sector (34-134217694, default = 10240) or {+-}size{KMGTP}: 10240
    Last sector (10240-1026047, default = 1026047) or {+-}size{KMGTP}: 1026047
    Current type is 'Linux filesystem'
    Hex code or GUID (L to show codes, Enter = 8300): ef00
    Changed type of partition to 'EFI System'
    
    Command (? for help): p
    Disk /dev/sdc: 134217728 sectors, 64.0 GiB
    Model: Virtual Disk    
    Sector size (logical/physical): 512/4096 bytes
    Disk identifier (GUID): <Disk GUID>
    Partition table holds up to 128 entries
    Main partition table begins at sector 2 and ends at sector 33
    First usable sector is 34, last usable sector is 134217694
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 4029 sectors (2.0 MiB)
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       1         1026048         3123199   1024.0 MiB  0700  
       2         3123200       134215679   62.5 GiB    8E00  
       3           10240         1026047   496.0 MiB   EF00  EFI System
      14            2048           10239   4.0 MiB     EF02  
    
    Command (? for help): w
    
    Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
    PARTITIONS!!
    
    Do you want to proceed? (Y/N): Y
    OK; writing new GUID partition table (GPT) to /dev/sdc.
    Warning: The kernel is still using the old partition table.
    The new table will be used at the next reboot or after you
    run partprobe(8) or kpartx(8)
    The operation has completed successfully.
    

    重要事項

    • 將取代 /dev/sdc 為操作系統 (OS) 磁碟裝置的對應複本。
    • 只要扇區起點和結束點正確無誤,分割區編號選擇就無關緊要。 選擇正確的扇區起點和終點,因為操作系統能夠判斷遺漏的扇區。
    • 確定磁碟內的任何其他磁碟分區不會佔用結束扇區。 在這裡,選擇預設值應該就已足夠。

    Azure Linux 合作夥伴映射具有下列分割區編號、扇區起點和扇區端點:

    Linux OS 散發套件 EFI 分割區編號 扇區開始 扇區結束
    CentOS 7 15 10240 1024000
    CentOS 8 15 10240 1024000
    Debian 10 15 8192 262143
    Debian 11 15 8192 262143
    RHEL 7 1 2048 1026047
    RHEL 8 15 10240 1024000
    Oracle Linux 7 15 10240 1024000
    Oracle Linux 8 15 10240 1024000
    Ubuntu 18.04 15 10240 227327
    Ubuntu 20.04 15 10240 227327
    SLES 12 2 6144 1054719
    SLES 15 2 6144 1054719
  3. 重新建立分割區之後,請使用 az vm repair restore 命令,將修復的 OS 磁碟與 VM 的原始 OS 磁碟交換,以還原 VM。 如需詳細資訊,請參閱 使用 Azure 虛擬機修復命令修復 Linux VM 中的步驟 5。

案例 2:開機映射中的 UEFI 磁碟分區已損毀

如果 UEFI 開機磁碟分區損毀,第 2 代 Linux VM 將無法開機。 若要解決此問題,請遵循下列步驟:

  1. 使用 az vm repair create 命令來建立修復 VM。 修復 VM 會有一份作業系統磁碟復本,用於連接的非功能性 VM。 如需詳細資訊,請參閱 使用 Azure 虛擬機修復命令修復 Linux VM

  2. 使用下列命令清除損毀的資料分割:

    root@repair-centos7:~# gdisk -l /dev/sdc
    GPT fdisk (gdisk) version 1.0.3
    
    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present
    
    Found valid GPT with protective MBR; using GPT.
    Disk /dev/sdc: 134217728 sectors, 64.0 GiB
    Model: Virtual Disk    
    Sector size (logical/physical): 512/4096 bytes
    Disk identifier (GUID): <Disk GUID>
    Partition table holds up to 128 entries
    Main partition table begins at sector 2 and ends at sector 33
    First usable sector is 34, last usable sector is 134217694
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 4029 sectors (2.0 MiB)
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       1         1026048         3123199   1024.0 MiB  0700  
       2         3123200       134215679   62.5 GiB    8E00  
       3           10240         1026047   496.0 MiB   EF00  EFI System
      14            2048           10239   4.0 MiB     EF02 
    
    root@repair-centos7:~# fsck.vfat -n /dev/sdc3
    fsck.fat 4.1 (2017-01-24)
    0x25: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.
     Automatically removing dirty bit.
    Leaving filesystem unchanged.
    /dev/sdc3: 19 files, 1438/63326 clusters
    
    root@repair-centos7:~# fsck.vfat /dev/sdc3
    fsck.fat 4.1 (2017-01-24)
    0x25: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.
    1) Remove dirty bit
    2) No action
    ? 1
    Perform changes ? (y/n) y
    /dev/sdc3: 19 files, 1438/63326 clusters
    root@repair-centos7:~# fsck.vfat /dev/sdc3
    fsck.fat 4.1 (2017-01-24)
    /dev/sdc3: 19 files, 1438/63326 clusters
    

    重要事項

    • 將取代 /dev/sdc 為對應的 OS 磁碟裝置復本。
    • 在執行上述文件系統檢查之前,請務必備份 OS 磁碟,並使用 選項執行試執行 -n
    • 命令 dosfsck 可用來執行 vfat 檔案系統檢查。 這兩個命令都相同。 如需詳細資訊,請參閱 fsck.vfat
  3. 清除分割區之後,請使用 az vm repair restore 命令,將修復的 OS 磁碟與 VM 的原始 OS 磁碟交換,以還原 VM。 如需詳細資訊,請參閱 使用 Azure 虛擬機修復命令修復 Linux VM 中的步驟 5。

案例 3:刪除整個 /boot 磁碟分區內容

如果遺漏整個 /boot 磁碟分區或其他重要內容,且無法復原,則從備份還原 VM 是唯一的選項。 如需詳細資訊,請參閱如何在 Azure 入口網站 中還原 Azure VM 數據

與我們連絡,以取得說明

如果您有問題或需要相關協助,請建立支援要求,或詢問 Azure community 支援。 您也可以將產品意見反應提交給 Azure 意應見反社群