September 26, 2019 · Steven A
Check if system (RHEL/CENTOS )is UEFI or BIOS
Please run the following script to find out if your system is UEFI or BIOS
#!/bin/bash
[ -d /sys/firmware/efi ] && fw=”UEFI” || fw=”BIOS”
echo -e “$fw”
if [ “$fw” == “UEFI” ] ; then
mygrub=’/boot/efi/EFI/redhat/grub.cfg’
echo -e “\n\tUEFI detected, this is a ($fw) system., and the boot config is located at ($mygrub)”
else
mygrub=’/boot/grub2/grub.cfg’
echo -e “\n\t($fw) system detected your boot config is located at ($mygrub)\n”
fi
The script’s check on /sys/firmware/efi is the quickest way to tell, but hardcoding the EFI grub path to redhat/grub.cfg can mislead on CentOS or RHEL derivatives where the vendor directory differs. Before trusting that path, run ls /boot/efi/EFI to see the actual directory name, then adjust the variable. Also note that efibootmgr -v shows the real boot entries the firmware uses, which is worth checking alongside the filesystem test.