Host enters grub mode after a power loss and restart
Cause
An unexpected power loss caused the /boot/grub2/grub.cfg file to be lost. The system cannot boot and enters grub> mode.
Solution
-
Resolve the issue from the grub page by following these steps:
-
In grub mode, run
lsto list partitions. Usels (hd0,gpt1)/grub2orls (hd0,gpt2)/grub2to find the partition containing thegrub2directory (the boot partition). The correct partition returnsdevice.map i386-pc/ locale/ fonts/ grubenv.grub> ls (hd0,gpt1)/grub2 -
Set the system partition:
grub> set root=(hd0,gpt1) -
Mount the root device (set the boot partition as the startup partition; determine the system location based on a working host):
grub> linuxefi /vmlinuz-3.10.0-957.27.6.da38eal.el7.x86_64 root=/dev/sde3 //`/dev/sde3` is the original `/` partition mount point; confirm this from another working physical node -
Specify the initialization image:
grub> initrdefi /initramfs-3.10.0-957.27.6.da38eal.el7.x86_64.img -
Boot the system:
grub> boot -
After the system boots, repair the EFI partition with the following steps:
# Generate the grub.cfg file [root@localhost ~]# grub2-mkconfig -o /root/grub.cfg # Unmount the `efi` partition to remount with updated permissions [root@localhost ~]# umount /boot/efi # Remount the `efi` partition with read-write permissions [root@localhost ~]# mount /dev/sde1 /boot/efi # Replace the damaged grub.cfg with the newly generated one [root@localhost ~]# mv /root/grub.cfg /boot/efi/EFI/helix/grub.cfg