禁用 VFAT 文件系统类型后,Azure Linux 虚拟机无法启动

注意

本文中引用的 CentOS 是 Linux 发行版, (EOL) 将达到生命周期结束。 相应地考虑使用和计划。 有关详细信息,请参阅 CentOS 生命周期终止指南

本文提供了以下问题的解决方案:在禁用虚拟文件分配表 (VFAT) 文件系统类型后,Azure Linux 虚拟机 (VM) 无法启动。

在以下方案中需要 VFAT:

  • Azure 上认可的 Linux 分发版 VM 装载 /boot/efi 文件系统。

    (基于 UEFI 的 Linux Gen2 VM) 需要 /boot/efi 文件系统,但它包含在 Gen1 (基于 BIOS) Linux 映像中。

  • 使用 Azure 磁盘加密 (ADE) 加密 Azure Linux VM 的 OS 和数据磁盘。

禁用 VFAT 将导致 Azure Linux VM 无法启动。 多个强化工具可以禁用 VFAT。 若要避免此类问题,请确保 VFAT 已从强化中排除并已启用。

先决条件

确保 串行控制台 在 Linux VM 中已启用且正常运行。

如何识别启动问题

若要确定启动问题,请使用 AZ CLI 或 Azure 门户在启动诊断窗格或串行控制台窗格中查看 VM 的串行控制台日志输出。 如果 VFAT 处于禁用状态,你将遇到以下问题:

无法装载 /boot/efi

/boot/efi 文件系统无法装载时,将显示以下一个或多个输出:

  • 输出 1

    [[1;31mFAILED[0m] Failed to mount /boot/efi.
    
    See 'systemctl status boot-efi.mount' for details.
    
    [[1;33mDEPEND[0m] Dependency failed for Local File Systems.
    
    [[1;33mDEPEND[0m] Dependency failed for Relabel all filesystems, if necessary.
    
    [[1;33mDEPEND[0m] Dependency failed for Migrate local... structure to the new structure.
    
    [[1;33mDEPEND[0m] Dependency failed for Mark the need to relabel after reboot.
    
  • 输出 2

    [FAILED] Failed to mount /boot/efi.
    See 'systemctl status boot-efi.mount' for details.
    [DEPEND] Dependency failed for Local File Systems.
    [DEPEND] Dependency failed for Mark the need to relabel after reboot.
    
  • 输出 3

    [   17.707983] ------------[ cut here ]------------
    [   17.714144] request_module fs-vfat succeeded, but still no fs?
    [   17.714426] RPC: Registered named UNIX socket transport module.
    [   17.721163] WARNING: CPU: 1 PID: 933 at fs/filesystems.c:275 get_fs_type+0xcd/0xe0
    [   17.738587] RPC: Registered udp transport module.
    [   17.722103] Modules linked in: fat sunrpc(+) rdma_ucm ib_srpt ib_isert iscsi_target_mod target_core_mod intel_rapl_msr intel_rapl_common isst_if_mbox_msr isst_if_common ib_iser libiscsi nfit scsi_transport_iscsi ib_umad libnvdimm rdma_cm ib_ipoib iw_cm ib_cm kvm_intel kvm irqbypass mlx5_ib crct10dif_pclmul crc32_pclmul ib_uverbs ghash_clmulni_intel rapl pcspkr ib_core i2c_piix4 hv_balloon hv_utils joydev ip_tables xfs libcrc32c mlx5_core mlxfw tls pci_hyperv pci_hyperv_intf ata_generic sd_mod t10_pi sg hv_storvsc hv_netvsc hyperv_keyboard scsi_transport_fc hid_hyperv hyperv_fb ata_piix libata hv_vmbus crc32c_intel serio_raw dm_mod
    [   17.766462] RPC: Registered tcp transport module.
    [   17.722103] CPU: 1 PID: 933 Comm: mount Not tainted 4.18.0-305.17.1.el8_4.x86_64 #1
    [   17.722103] Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS 090008  12/07/2018
    [   17.722103] RIP: 0010:get_fs_type+0xcd/0xe0
    [   17.722103] Code: 5d 41 5c c3 80 3d 6a 7a 49 01 00 75 ec 48 89 da 44 89 e6 48 89 04 24 48 c7 c7 c8 47 ce b7 c6 05 50 7a 49 01 01 e8 6c 67 da ff <0f> 0b 48 8b 04 24 e9 66 ff ff ff 0f 1f 84 00 00 00 00 00 0f 1f 44
    [   17.722103] RSP: 0018:ffffabd68394fe70 EFLAGS: 00010282
    [   17.722103] RAX: 0000000000000000 RBX: ffffa04a1e6879e0 RCX: 0000000000000000
    [   17.722103] RDX: ffffa04a37d267a0 RSI: ffffa04a37d167c8 RDI: ffffa04a37d167c8
    [   17.722103] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000092
    [   17.722103] R10: 00000000ff000000 R11: ffffabd682fec020 R12: 0000000000000004
    [   17.722103] R13: ffffa04a1d80f920 R14: ffffa04a1e6879e0 R15: 0000000000000000
    [   17.722103] FS:  00007fb0630e1080(0000) GS:ffffa04a37d00000(0000) knlGS:0000000000000000
    [   17.722103] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [   17.722103] CR2: 00007fb86bb7a0c0 CR3: 000000029bfe4004 CR4: 00000000003706e0
    [   17.722103] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    [   17.722103] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    [   17.722103] Call Trace:
    [   17.722103]  do_mount+0x1f2/0x950
    [   17.722103]  ksys_mount+0xb6/0xd0
    [   17.722103]  __x64_sys_mount+0x21/0x30
    [   17.722103]  do_syscall_64+0x5b/0x1a0
    [   17.722103]  entry_SYSCALL_64_after_hwframe+0x65/0xca
    [   17.874253] RPC: Registered tcp NFSv4.1 backchannel transport module.
    [   17.722103] RIP: 0033:0x7fb06211192e
    [   17.722103] Code: 48 8b 0d 5d 15 2c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 2a 15 2c 00 f7 d8 64 89 01 48
    [   17.722103] RSP: 002b:00007fff02a92b78 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
    [   17.722103] RAX: ffffffffffffffda RBX: 00005626752f3460 RCX: 00007fb06211192e
    [   17.722103] RDX: 00005626752f36e0 RSI: 00005626752f3700 RDI: 00005626752f53d0
    [   17.722103] RBP: 00007fb062ebe184 R08: 00005626752f3670 R09: 0000000000000003
    [   17.722103] R10: 00000000c0ed0000 R11: 0000000000000246 R12: 0000000000000000
    [   17.722103] R13: 00000000c0ed0000 R14: 00005626752f53d0 R15: 00005626752f36e0
    [   17.722103] ---[ end trace 910fa795ff1c6c89 ]---
    [[0;1;31mFAILED[0m] Failed to mount /boot/efi.
    
    See 'systemctl status boot-efi.mount' for details.
    

ADE 加密的 VM 无法访问根卷

当 OS 加密并禁用 VFAT 的 VM 无法启动时,将显示相应的输出,如下所示。 系统超时后,dracut 或 initramfs shell 将显示在串行控制台日志的末尾。

  • OS 磁盘已加密并禁用 VFAT 的 Ubuntu VM:

        [   24.062228] dracut-initqueue[261]: +++ '[' -z 0 ']'
        [   24.065039] dracut-initqueue[261]: + luksname=osencrypt
        [   24.068026] dracut-initqueue[261]: + ask_passphrase=1
        [   24.070498] dracut-initqueue[261]: + '[' /dev/sda2 '!=' /dev/sda2 ']'
        [   24.073528] dracut-initqueue[261]: + device=/dev/sda2
        [   24.076046] dracut-initqueue[261]: + numtries=1
        [   24.078410] dracut-initqueue[261]: + info 'luksOpen /dev/sda2 osencrypt'
        [   24.081822] dracut-initqueue[261]: + check_quiet
        [   24.084663] dracut-initqueue[261]: + '[' -z no ']'
        [   24.087067] dracut-initqueue[261]: + '[' no '!=' yes ']'
        [   24.089711] dracut-initqueue[261]: + echo 'luksOpen /dev/sda2 osencrypt'
        [   24.092857] dracut-initqueue[261]: luksOpen /dev/sda2 osencrypt
        [   24.095737] dracut-initqueue[261]: + ls '/mnt/azure_bek_disk/LinuxPassPhraseFileName*'
        [   24.099506] dracut-initqueue[261]: ls: cannot access /mnt/azure_bek_disk/LinuxPassPhraseFileName*: No such file or directory
        [   24.104460] dracut-initqueue[261]: + mkdir -p /mnt/azure_bek_disk/
        [   24.107648] dracut-initqueue[261]: + mount -L 'BEK VOLUME' /mnt/azure_bek_disk/
        [   24.111029] dracut-initqueue[261]: mount: unknown filesystem type 'vfat'
        [   24.114456] dracut-initqueue[261]: ++ ls '/mnt/azure_bek_disk/LinuxPassPhraseFileName*'
        [   24.118570] dracut-initqueue[261]: ls: cannot access /mnt/azure_bek_disk/LinuxPassPhraseFileName*: No such file or directory
        [   24.124108] dracut-initqueue[261]: + cryptsetupopts='--header /osluksheader'
        [   24.127630] dracut-initqueue[261]: + '[' -n '' -a '' '!=' none -a -e '' ']'
        [   24.131265] dracut-initqueue[261]: + '[' 1 -eq 0 ']'
        [   24.134614] dracut-initqueue[261]: + sleep 1 
        [   24.817478] dracut-initqueue[261]: + info 'No key found for /dev/sda2.  Will try 1 time(s) more later.'
        [   24.823243] dracut-initqueue[261]: + check_quiet
    
  • 已加密 OS 磁盘并禁用 VFAT 的 RHEL 7.x VM:

    %G%G[[32m  OK  [0m] Found device Virtual_Disk BEK_VOLUME.
    
             Mounting /bek...
    
    [[1;31mFAILED[0m] Failed to mount /bek.
    
    See 'systemctl status bek.mount' for details.
    
  • 已加密 OS 磁盘并禁用 VFAT 的 RHEL 8.x VM:

    [   11.592932] dracut-initqueue[470]: + systemctl start bek.mount
    [   11.600362] dracut-initqueue[470]: Bus n/a: changing state UNSET → OPENING         Mounting /bek...
    
    [   11.611171] dracut-initqueue[470]: Bus n/a: changing state OPENING → AUTHENTICATING
    [   11.616206] dracut-initqueue[470]: Executing dbus call org.freedesktop.systemd1.Manager StartUnit(bek.mount, replace)
    [   11.622972] dracut-initqueue[470]: Bus n/a: changing state AUTHENTICATING → RUNNING
    [   11.628048] dracut-initqueue[470]: Sent message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=StartUnit cookie=1 reply_cookie=0 signature=ss error-name=n/a error-message=n/a
    [   11.639221] dracut-initqueue[470]: Got message type=method_return sender=org.freedesktop.systemd1 destination=n/a path=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 signature=o error-name=n/a error-message=n/a[[0;1;31mFAILED[0m] Failed to mount /bek.
    See 'systemctl status bek.mount' for details.
    
  • 在某些旧系统中,可能会在 Azure 串行控制台中看到以下错误:

    未知的文件系统类型“vfat”错误。

出现此问题的所有 VM 最终将卡在 dracut/initramfs 上,并显示在串行控制台日志的末尾:

  • RHEL/CentOS/SLES:

    ///lib/dracut/hooks/emergency/80-\x2fdev\x2fmapper\x2frootvg-rootlv.sh@1(source): warn '/dev/mapper/rootvg-rootlv does not exist'
    //lib/dracut-lib.sh@79(warn): echo 'Warning: /dev/mapper/rootvg-rootlv does not exist'
    Warning: /dev/mapper/rootvg-rootlv does not exist
    /bin/dracut-emergency@19(main): echo
    ...
    /bin/dracut-emergency@29(main): '[' -f /run/dracut/fsck/fsck_help_auto.txt ']'
    /bin/dracut-emergency@30(main): '[' -f /etc/profile ']'
    /bin/dracut-emergency@30(main): . /etc/profile
    //etc/profile@1(source): PS1='dracut:${PWD}# '
    /bin/dracut-emergency@31(main): '[' -z 'dracut:${PWD}# ' ']'
    /bin/dracut-emergency@32(main): exec sh -i -l
    dracut:/# 
    
  • Ubuntu:

    Gave up waiting for root file system device.  Common problems:
     - Boot args (cat /proc/cmdline)
       - Check rootdelay= (did the system wait long enough?)
     - Missing modules (cat /proc/modules; ls /dev)
    ALERT!  /dev/mapper/osencrypt does not exist.  Dropping to a shell!
    
    
    BusyBox v1.27.2 (Ubuntu 1:1.27.2-2ubuntu3.4) built-in shell (ash)
    Enter 'help' for a list of built-in commands.
    
    (initramfs)
    

若要解决启动问题,请转到 联机故障排除脱机故障排除

注意

如果 OS 磁盘未加密,并且仅使用 ADE 加密数据文件系统,则无法装载 ADE 加密的数据磁盘,因为 VFAT 已禁用。 在这种情况下,请按照 联机故障排除脱机故障排除 中的相同步骤解决此问题。

联机故障排除

提示

如果在禁用 VFAT 之前有 VM 的最新备份, 请从备份还原 VM 以修复启动问题。

串行控制台是解决此问题的最快方法。 它允许你直接修复问题,而无需将系统磁盘呈现给恢复 VM。 请确保满足分发所需的先决条件。 有关详细信息,请参阅 适用于 Linux 的虚拟机串行控制台

未加密的 VM 无法装载 /boot/efi

  1. 使用 Azure 串行控制台 在单用户模式下启动 VM。 有关详细信息,请参阅 使用串行控制台访问 GRUB 和单用户模式

    若要在单用户模式下启动 VM,请在 GRUB 菜单级别中断启动过程,并编辑main内核条目,以在以 linux开头的 GRUB 行中添加init=/bin/bash内核选项。

    显示在 GRUB 菜单级别中断启动进程以在单用户模式下启动系统的过程的动画 GIF。

  2. 请确保装载了所有必需的文件系统,并且根目录处于读取和写入模式。

    1. 如果使用内核选项启动系统 init=/bin/bash ,请运行以下命令来准备所需的文件系统:

      mount -o rw,remount /
      mount -a
      
    2. 重新启用 VFAT

    3. 重新启动系统。

注意

如果 VM 是 Gen1 且未加密,则还可以简单地注释掉 /boot/efi/etc/fstab 中的条目,因为 /boot/efi Gen1 VM 中不需要。 有关详细信息,请参阅 排查由于 fstab 错误而导致的 Linux VM 启动问题

ADE 加密的 VM 无法启动

  • OS 磁盘已加密的 VM:

    OS 磁盘加密后,无法从 Azure 串行控制台排查此问题。

  • 由于 /etc/fstab 问题,仅加密了数据磁盘的 VM 无法启动:

    1. 如果仅加密 VM 数据磁盘 (OS 磁盘未) 加密,则若要启动系统,请使用 Azure 串行控制台装载选项添加到 nofail/etc/fstab 中的相应条目。 有关详细信息,请参阅 排查由于 fstab 错误而导致的 Linux VM 启动问题

    2. 启动 VM 后, 重新启用 VFAT 并重启 VM。

脱机故障排除

提示

如果在禁用 VFAT 之前有 VM 的最新备份, 请从备份还原 VM 以修复启动问题。

如果 Azure 串行控制台 在特定 VM 中不起作用或订阅中不是选项,请使用救援/修复 VM 来排查此问题。

未加密的 VM 无法装载 /boot/efi

  1. 使用 vm 修复命令 创建一个修复 VM,该 VM 附加了受影响 VM 的 OS 磁盘的副本。 使用 chroot 在修复 VM 中装载 OS 文件系统的副本。

    注意

    或者,可以使用 Azure 门户手动创建救援 VM。 有关详细信息,请参阅使用 Azure 门户将 OS 磁盘附加到恢复 VM,对 Linux VM 进行故障排除

  2. 重新启用 VFAT

  3. 重新启用 VFAT 后,执行以下操作:

    1. 退出 chroot 并从救援/修复 VM 中卸载文件系统的副本。

    2. az vm repair restore运行 命令,将修复的 OS 磁盘与 VM 的原始 OS 磁盘交换。 有关详细信息,请参阅 使用 Azure 虚拟机修复命令修复 Linux VM 中的步骤 5。

    3. 通过查看 Azure 串行控制台或尝试连接到 VM 来验证 VM 是否能够启动。

注意

如果 VM 是 Gen1 且未加密,则还可以简单地注释掉 /boot/efi/etc/fstab 中的条目,因为 /boot/efi Gen1 VM 中不需要。 有关详细信息,请参阅 排查由于 fstab 错误而导致的 Linux VM 启动问题

ADE 加密的 VM 无法启动

  1. 使用 vm 修复命令 创建一个修复 VM,该 VM 附加了受影响 VM 的 OS 磁盘的副本。

  2. 使用 ADE 加密 VM 时, Azure VM 修复命令 负责解锁和装载加密的文件系统。 加密的文件系统将装载为 /investigateroot/*/investigateboot。 可以使用 chroot 登录到修复 VM 并将文件系统重新装载到所需的装入点。

    注意

    或者,可以使用 Azure 门户并在创建 VM 时附加加密的 OS 磁盘的副本,手动创建救援 VM。 有关详细信息,请参阅使用 Azure 门户将 OS 磁盘附加到恢复 VM,对 Linux VM 进行故障排除

  3. 重新启用 VFAT

  4. 重新启用 VFAT 后,执行以下操作:

    1. 退出 chroot 并从救援/修复 VM 中卸载文件系统的副本。

    2. az vm repair restore运行 命令,将修复的 OS 磁盘与 VM 的原始 OS 磁盘交换。 有关详细信息,请参阅 使用 Azure 虚拟机修复命令修复 Linux VM 中的步骤 5。

    3. 通过查看 Azure 串行控制台或尝试连接到 VM 来验证 VM 是否能够启动。

重新启用 VFAT

  1. 通过运行以下命令标识禁用 VFAT 的文件和相应的行号:

    grep -nr vfat /etc/modprobe.d/
    
  2. 修改相应的文件并注释掉或删除 VFAT 条目。 条目通常为: install vfat /bin/true

    vi /etc/modprobe.d/disable.conf
    

    注意

    将 替换为 disable.conf 禁用 VFAT 的相应文件名。

  3. 使用下列相应的命令重新生成 initramfs 文件:

    • 从 Azure 串行控制台运行 命令:

      • RHEL/CentOS/Oracle Linux 7/8

        dracut -f /boot/initramfs-$(uname -r).img $(uname -r)
        
      • SLES 12/15

        dracut -f /boot/initrd-$(uname -r) $(uname -r)
        
      • Ubuntu 18.04

        mkinitramfs -k -o /boot/initrd.img-$(uname -r)
        
    • 从修复/救援 VM 运行命令:

      重要

      请确保遵循 脱机故障排除 中的步骤 1,并在 chroot 中执行这些命令。

      • RHEL/CentOS/Oracle Linux 7/8

        dracut -f /boot/initramfs-3.10.0-1160.59.1.el7.x86_64.img 3.10.0-1160.59.1.el7.x86_64
        

        重要

        将 替换为 3.10.0-1160.59.1.el7.x86_64 相应的内核版本。

      • SLES 12/15

        dracut -f /boot/initrd-5.3.18-150300.38.53-azure 5.3.18-150300.38.53-azure
        

        重要

        将 替换为 5.3.18-150300.38.53-azure 相应的内核版本。

      • Ubuntu 18.04

        mkinitramfs -k -o /boot/initrd.img-5.4.0-1077-azure
        

        重要

        将 替换为 5.4.0-1077-azure 相应的内核版本。

后续步骤

如果特定启动错误不是禁用 VFAT 的问题,请参阅排查 Azure Linux 虚拟机启动错误以获取进一步的故障排除选项。

联系我们寻求帮助

如果你有任何疑问或需要帮助,请创建支持请求联系 Azure 社区支持。 还可以向 Azure 反馈社区提交产品反馈。