CentOS/RHEL 7 : How to Recover Missing grub.cfg file in Rescue Mode Using ISO
The Problem
A system is not able to boot and is stuck at the GRUB prompt.
The Solution
The system can fail to boot if the grub.cfg file is not present. That is what is happening here. Follow the steps outlined below to recover the missing grub.cfg file.
0. First Boot the system into rescue mode using ISO.
1. If you allowed it, your root file-system should be mounted as the /mnt/sysimage directory. For example, your /etc/fstab will be present at the /mnt/sysimage/etc/fstab location. Now change root directory and make sure there is no grub.cfg file under /etc/ and proceed with the further steps.
# chroot /mnt/sysimage
# cd /mnt/sysimage/boot/grub2/
# ls ### This command shall not show grub.cfg file
2. Create a grub configuration file under /boot/grub2/ directory.
# grub2-mkconfig -o /boot/grub2/grub.cfg
3. Create a symlink from /boot/grub2/grub.cfg file to /etc/grub2.cfg file.
# ln -s /boot/grub2/grub.cfg /etc/grub2.cfg
4. Exit from the current shell.
# exit
5. Reboot the server.
# reboot