> For the complete documentation index, see [llms.txt](https://docs.verge.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.verge.io/knowledge-base/zh/backup-dr/rhel9-boot-failure-clone-snapshot-restore.md).

# RHEL 9 系列虚拟机在克隆或快照还原后无法启动

本指南涵盖一种特定的启动失败：一台 RHEL 9 系列虚拟机（RHEL、AlmaLinux 9、Rocky Linux 9 或 CentOS Stream 9）在源端可以正常启动，但在克隆或从快照恢复后的实例上启动失败，因为 LVM 的 system.devices 文件不再匹配该虚拟机磁盘序列号。下面的步骤可从救援模式修复该虚拟机。如果你还没有执行克隆或恢复，请参见下面的“*防止未来的克隆、快照或导出出现此问题*”注释。

## 症状

* 从快照恢复虚拟机，或克隆虚拟机后，RHEL 9 虚拟机无法启动（进入紧急模式或卡在启动过程中）
* 在救援模式下，vgchange -ay 没有任何输出，lvdisplay 也不显示内容

## 概述

RHEL 9 及其衍生版（AlmaLinux 9、Rocky Linux 9、CentOS Stream 9）使用位于 `/etc/lvm/devices/system.devices` 的 LVM 设备文件，它会通过唯一标识符——最主要是磁盘序列号——显式白名单化块设备。在启动时，LVM 在组装卷组时只会考虑此文件中列出的设备。如果它看到的序列号与创建该文件时记录的不匹配，LVM 就不会激活根卷组，虚拟机也会掉入 dracut 紧急 shell。

这意味着任何会让虚拟机获得新磁盘序列号的操作——例如克隆虚拟机并生成新的硬件序列号，或以会更改序列号的方式恢复快照——都会导致启动过程失败。

{% hint style="info" %}
**VergeOS 26.1.5 及更高版本**

从 VergeOS 26.1.5 开始，虚拟机克隆和快照恢复 **默认会保留原始磁盘序列号**，从而消除了大多数克隆和恢复操作中的序列号不匹配问题。此问题最常影响：

* 明确选择生成新硬件序列号的克隆或恢复操作
* 运行 VergeOS 26.1.5 之前版本的环境
  {% endhint %}

{% hint style="info" %}
**从其他虚拟化平台导入**

当从其他虚拟化平台导入虚拟机时，也可能出现相同的启动失败， *如果* 虚拟机导出时没有保留其原始设备序列号。此外，导入的虚拟机还可能因为缺少 VergeOS 硬件的 virtio 驱动而无法启动。请参见 [导入 Linux 虚拟机指南](/knowledge-base/zh/virtual-machines/import-rhel-centos-vm.md) ，其中包含调整虚拟机配置并使用 virtio 驱动重新生成 initramfs 的说明。
{% endhint %}

{% hint style="info" %}
**防止未来的克隆、快照或导出出现此问题**

如果你仍然可以访问正常运行的源虚拟机，可以通过在未来的克隆、快照或从其他虚拟化平台导出时禁用 LVM 设备文件来避免启动失败 *在* 该操作。设置 `use_devicesfile = 0` 在 `/etc/lvm/lvm.conf` 中（在来宾系统内）。LVM 将回退为扫描所有可用的块设备，而不考虑序列号。LVM 设备文件主要是为连接到 SAN 结构的主机设计的，在这种情况下，一台机器可以看到许多不属于它的块设备；而在典型的 VergeOS 环境中，虚拟机只会看到显式分配给它的虚拟磁盘，因此它提供的保护通常并不需要。有关该设备文件的更多信息，请参见红帽的 [限制 LVM 设备可见性和使用](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/configuring_and_managing_logical_volumes/limiting-lvm-device-visibility-and-usage_configuring-and-managing-logical-volumes) 。
{% endhint %}

## 前提条件

* 可访问 VergeOS UI 和虚拟机控制台
* 可在 VergeOS 媒体中获取的 RHEL 9 系列安装 ISO（仅当虚拟机无法进入 GRUB 菜单时才需要）

## 步骤

### 1. 启动到救援环境

虚拟机很可能无法正常启动。请使用以下方法之一进入可用的 shell。

#### 选项 A — GRUB 救援内核（推荐）

* 启动虚拟机并在 VergeOS 中打开控制台。
* 在启动过程中，按住 **Shift** （BIOS）或 **Esc** （UEFI）以进入 GRUB 菜单。
* 选择 **高级选项** 并选择 **救援** 内核条目。
* 按照任何提示操作——如果询问是否挂载根文件系统，请选择 **继续**.

#### 选项 B — 从安装 ISO 启动

如果无法进入 GRUB 菜单，或者虚拟机根本无法走到那一步：

* 在 VergeOS 中，将一个 RHEL 9 系列安装 ISO 作为 CD/DVD 驱动器附加到虚拟机。
* 调整虚拟机的启动顺序，使其首先从 ISO 启动，或者使用一次性启动选项。
* 在安装程序菜单中，导航到 **故障排除 → 救援一个 \[distro] 系统**.
* 当提示是否挂载已安装系统时，选择选项 **1** （挂载到 `/mnt/sysimage`).
* 选择 **Shell** 以打开命令提示符。

{% hint style="warning" %}
**ISO 救援使用不同的挂载路径**

使用安装程序救援模式时，你的已安装系统位于 `/mnt/sysimage` 而不是 `/mnt`。请相应调整后续步骤。
{% endhint %}

### 2. 确认磁盘可见、重新扫描并验证卷组

* **显示块设备：**

  `lsblk`

  记下设备名称（例如 /dev/sda）以及 LVM 分区（例如 /dev/sda3）
* **强制 LVM 重新扫描所有块设备（绕过 devices 文件）：**

  `pvscan --cache`\
  `vgchange -ay`
* **如果重新扫描后仍然没有显示内容，请显式注册 LVM 分区：**

  `lvmdevices --adddev /dev/sda3` 请替换为你在 lsblk 中看到的实际 LVM 分区\
  `vgchange -ay`

  <div data-gb-custom-block data-tag="hint" data-style="success" class="hint hint-success"><p><strong>RHEL 9 安装通常使用 LVM，根逻辑卷位于 <code>/dev/mapper/rhel-root</code> （或 <code>almalinux-root</code>, <code>rocky-root</code>).</strong></p></div>
* 验证卷组现在是否可见

  `lvdisplay`

### 3. 挂载根分区并绑定文件系统

* `mount /dev/<device_name> /mnt`\
  请将 \<device\_name> 替换为你的根分区（例如 sda2、mapper/vg0-root）。
* **验证挂载：**

  `ls /mnt`

  你应该能看到 /root、/boot、/home、/etc 和 /var 等目录。
* **绑定文件系统：**

  **使用以下 for 循环来绑定所需的虚拟文件系统：**

  `for i in proc sys dev run; do mount --rbind /$i /mnt/$i; done`

  **或者分别挂载它们：**

  `mount --rbind /proc /mnt/proc`\
  `mount --rbind /sys /mnt/sys`\
  `mount --rbind /dev /mnt/dev`\
  `mount --rbind /run /mnt/run`

  对于 EFI/UEFI 系统，还要挂载 EFI 分区：

  ```bash
  mount /dev/sdX1 /mnt/boot/efi
  ```

  请将 /dev/sdX1 替换为你的实际 EFI 分区（使用 lsblk 或 fdisk -l 检查）。

### 4. 进入已安装系统的 chroot 并挂载其他文件系统

* **更改根目录**

  `chroot /mnt`
* 进入 chroot 后， **挂载在 fstab 中** 定义的任何其他分区：

  `mount -a`

### 5. 重新生成 Initramfs

* **重建 initramfs** 以便它获取清理后的设备配置：

  `dracut -f --regenerate-all`

### 6. 重启并验证

* **退出 chroot 环境：**

  `exit`
* **重启虚拟机：**

  `reboot`
* \*\*验证启动：\*\*确认虚拟机已成功启动，并且所有驱动器都如预期般出现。

## 故障排除

{% hint style="warning" %}
**无法进入 GRUB 菜单**

如果虚拟机完全不显示 GRUB，请使用第 1 步中的选项 B，通过安装 ISO 启动进入救援模式。
{% endhint %}

{% hint style="warning" %}
**启动后没有网络**

* 确认 NIC 已设置为 **virtio** ，在 VergeOS 虚拟机设置中。
* 检查是否存在任何持久网络规则（`70-persistent-net.rules`），这些规则可能会阻止新接口被正确命名。
* 运行 `ip link show` 查看 NIC 是否存在但尚未配置，然后检查 `/etc/sysconfig/network-scripts/` 或 NetworkManager 中的接口配置。
  {% endhint %}

## 其他资源

* [限制 LVM 设备可见性和使用（红帽）](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/configuring_and_managing_logical_volumes/limiting-lvm-device-visibility-and-usage_configuring-and-managing-logical-volumes)
* [配置和管理逻辑卷（红帽）](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/configuring_and_managing_logical_volumes/index)
* [导入 Linux 虚拟机 — 通用指南](/knowledge-base/zh/virtual-machines/import-rhel-centos-vm.md)
* [虚拟机最佳实践](/run-the-platform/virtual-machines/vm-best-practices.md)

{% hint style="info" %}
**需要帮助吗？**

如果按照本指南操作后仍然遇到启动问题，请联系 VergeOS 支持以获得帮助。
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.verge.io/knowledge-base/zh/backup-dr/rhel9-boot-failure-clone-snapshot-restore.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
