After migrating a Red Hat Enterprise Linux 9 (RHEL 9) server from a physical machine to a VMware virtual machine (P2V), the virtual machine fails to boot into the OS normally. It repeatedly falls back to either Emergency Mode or the grub> prompt console.
VMware vSphere ESXi 8.x
Red Hat Enterprise Linux 9
Cause 1: /etc/fstab Disk UUID Mismatch During the P2V process, the UUIDs of the new virtual disk partitions (/dev/sda#, /dev/sda##) changed. Consequently, the OS failed to locate and mount the physical machine's original /boot and /boot/efi mount points during startup, triggering a mount lockup and forcing the system into Emergency Mode or the grub> prompt.
Cause 2: Missing UEFI NVRAM Boot Entries & Path Incompatibility The target virtual machine lacks the original NVRAM boot entries from the source physical machine. Additionally, there is a path compatibility gap between RHEL 9's default UEFI boot structure and ESXi's fallback boot mechanism, causing GRUB to fail to locate its configuration file upon reboot.
The issue of logging into the OS was resolved by following the steps below:
Step 1: Manually Boot into the Operating System
At the grub> prompt, execute the following commands in sequence (use the Tab key for auto-completion if needed):
set root=(lvm/rhel-root)
linux (hd0,gpt2)/vmlinuz-5.14.0-503.11.1.el9_5.x86_64 root=/dev/mapper/rhel-root ro
initrd (hd0,gpt2)/initramfs-5.14.0-503.11.1.el9_5.x86_64.img
boot
Step 2: Log In to the OS
Once the boot process completes and the snlpemmod01 login: prompt appears, enter root and the corresponding password to log in.
Step 3: Remount System and Boot Partitions
After logging in, execute the following commands in the terminal to remount the root filesystem as read-write and mount the /boot and /boot/efi partitions:
mount -o remount,rw /
mount /dev/sda2 /boot
mount /dev/sda1 /boot/efi
Step 4: Create the Universal BOOT Directory
Create the generic UEFI boot path directory if it does not exist:
mkdir -p /boot/efi/EFI/BOOT
Step 5: Sync GRUB Configuration across Boot Paths
Copy the main GRUB configuration file to all potential boot locations:
cp /boot/grub2/grub.cfg /boot/efi/EFI/BOOT/grub.cfg
cp /boot/grub2/grub.cfg /boot/efi/EFI/redhat/grub.cfg
Note: If prompted to overwrite, enter y and press Enter.
Step 6: Copy and Rename EFI Executable Files
Copy and rename the required EFI bootloader files to resolve ESXi fallback boot path issues:
cp /boot/efi/EFI/redhat/grubx64.efi /boot/efi/EFI/BOOT/BOOTX64.EFI
cp /boot/efi/EFI/redhat/shimx64.efi /boot/efi/EFI/BOOT/bootx64.efi
Note: If prompted to overwrite, enter y and press Enter.
Step 7: Re-register the UEFI Boot Entry
Use efibootmgr to re-register the Red Hat Linux boot entry in the VM's UEFI BIOS:
efibootmgr -c -d /dev/sda -p 1 -L "Red Hat Enterprise Linux" -l '\EFI\redhat\shimx64.efi'
Step 8: Reboot the Virtual Machine
reboot
Upon rebooting, the virtual machine successfully bypasses the grub> prompt and automatically loads into the normal OS Login prompt (snlpemmod01 login:). All system partitions and LVM logical volumes are mounted properly.