My virtual machine running RHEL 9 enters emergency mode. What can I do?

My virtual machine running RHEL 9 enters emergency mode. What can I do?

Symptoms

In Virtual Machine Manager, your virtual machines running Red Hat Enterprise Linux 9 (RHEL 9) enter emergency mode and display the following message:

1.png

After you log in with root password and enter the ls /dev/mapper/rhel-home command, you can see the following message:

ls: cannot access '/dev/mapper/rhel-home': No such file or directory

Diagnosis

In RHEL 9.0, the use_devicesfile option in Logical Volume Manager (LVM) is enabled by default, checking whether the Physical Volume Identifier (PVID) of the LVM volume is identical to the last time the virtual machine was running. When it is not identical, the virtual machine may enter emergency mode. However, the following operations will result in different PVIDs:

  • Change the virtual disk controller from VirtIO SCSI to IDE or SATA.
  • Clone a virtual machine with VirtIO SCSI controller.
  • Import a virtual machine with VirtIO SCSI controller which was exported previously.

Therefore, after the operations above, your virtual machine may enter emergency mode.

Resolution

Recover the virtual machine from the emergency mode

  1. In emergency mode, enter the root password of the virtual machine.
  2. Enter the command below to delete the original device file.
    [root@localhost ~]# rm /etc/lvm/devices/system.devices
  3. Enter the command below to create a new device file.
    [root@localhost ~]# vgimportdevices -a
  4. Enter the command below to reboot the virtual machine.
    [root@localhost ~]# reboot

Prevent the virtual machine from entering emergency mode

  1. Open the configuration file /etc/lvm/lvm.conf.
  2. Locate the use_devicesfile option.
    # use_devicesfile = 0
  3. Uncomment the option and make sure it is set to 0.
    use_devicesfile = 0
Symptoms
Diagnosis
Resolution
Recover the virtual machine from the emergency mode
Prevent the virtual machine from entering emergency mode