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.
The script relies on the firmware directory check, but the grub path it prints for UEFI won’t always match reality since some systems use /boot/efi/EFI/centos/grub.cfg or a vendor-specific directory. Before trusting the printed path, run a quick check like ls /boot/efi/EFI/ to see the actual vendor folder name, then confirm the config exists there. Also worth verifying with efibootmgr -v when it’s installed, since that shows the boot entries directly rather than inferring from a single directory.