Grub2 EFI issue when replacing mdadm raid 1 boot drive

On Rocky 8.5, one of the raid 1 drive died. Replaced it and it is syncing now. All that is good.

The problem is when installing grub2 on the new drive. Did the following,
grub2-install /dev/sda

But it gives the following error.
grub2-install: error: /usr/lib/grub/x86_64-efi/ doesn’t exist. Please specify --target or --directory

Anyone know how to solve this?

Tried searching the internet and tried suggestions to install grub2-efi-modules but does not work.

Any pointers? What I have have missed.

So removed my reply to try what you already tried (install grub2-efi rpms), but how does it “not work” exactly? What errors or new output occur?

On the thread title you say “EFI”.

The EFI firmaware on the motherboard is capable of reading GPT partition table, locate ESP (EFI System Partition), and load bootloader (*.efi binary) from ESP. If the RAID array mirrors the ESP, then you will have intact ESP on both drives. What else should you install?

Compare that to legacy boot procedure: the firmware on the motherboard reads first sector (0) of a drive. That contains first stage of bootloader that is somehow able to read other stages from a partition/filesystem. Unless hardware RAID mirrors entire disks, the sector 0 of each drive must have a copy of the first stage and pointer to partition that contains rest. That you would have to install (if you don’t have hardware RAID).

Thank you for replying and helping. Really do appreciate it very much.

You are correct about the EFI is capable of reading GPT partition table and locate the ESP and boot directly. Just did a test on another server and it works.

It was my lack of knowledge of EFI and my mind stuck in the bios world.

My bad for the noise.

Thank you again for taking the time to reply and help. Thank you very much.

I was so stressed. With this advice I am relieved

My bad for not giving enough details.

The issue is solved. The solution is that I do not have to do grub2-install because this is a EFI and not the old bios way.

Thank you for taking the time to reply.