I use EFI booting on a Macbook pro. (I can't use UEFI because the machine is too old.)
On the internal drive, I have Ubuntu Linux 20.04.
I had the unfortunate idea to install Ubuntu Linux 20.04 on an external drive from live USB. (I am trying to make a clone with incremental backup, which apparently no existing software does for Linux.)
When starting with the external drive connected, I see GNU GRUB 2.04 boot menu. By default, the external drive will boot first but I have a choice for booting on the internal drive.
When the external drive is not connected, I fall in the GRUB shell and cannot boot. I have read How to Rescue a Non-booting GRUB 2 on Linux but I always ended up with "end kernel panic... unable to mount root fs...".
Anyway, as long as I can still boot without GRUB shell, I just need to restore the internal drive to boot normally Ubuntu Linux.
This looks very simple.
After booting on the internal drive and disconnecting the external drive, I have tried
sudo update-grub but it does not help.
I have tried to change the boot order with
sudo efibootmgr but it gets worse, since I always end up in GRUB shell. (Fortunately, the change is reversible.)
If possible, eventually, I would like to get rid of GRUB. The Mac does not need GRUB because when it is started with the alt key pressed, it presents all bootable partitions in a simple graphical menu, so it would be very easy to choose any EFI partition and boot thereon without GRUB.
EDIT after first answer (thanks)
"something has caused the GRUB on the internal disk to be rewritten". YES, it is the live Ubuntu Linux installer, a dangerous thing indeed. I should have been more cautious: unmount the internal drive before installing Ubuntu Linux on the external drive. Indeed I found out that something had changed in /boot/efi on the internal drive. I restored the files exactly as explained in Ubuntu EFI booting fails after Mac OS X booting.
After rebooting, with external drive connected, I discovered a new situation: no GRUB menu, so I was forced to go with GRUB shell, but fortunately I could
ls the internal drive (instead of previously the external drive only) and apply this tutorial How to Rescue a Non-booting GRUB 2 on Linux to boot on internal drive.
So now I need to make boot happen automatically and, if possible, keep the option to boot on the external drive.
The grub.cfg on internal drive:
mac2011-linux# pwd /boot/efi/EFI mac2011-linux# more ubuntu/grub.cfg search.fs_uuid 770e447c-7411-4cc7-bce4-b71504d828c3 root hd2,gpt4 set prefix=($root)'/boot/grub' configfile $prefix/grub.cfg
As I have no separate boot filesystem, prefix is correct. I can see in
uuid 770e447c-7411-4cc7-bce4-b71504d828c3 is
/dev/sdb4 on external drive. This is not correct. How to fix it cleanly?
mac2011-linux# ls APPLE BOOT tools ubuntu mac2011-linux# mac2011-linux# ls -l BOOT total 5367 -rwx------ 1 root root 1677176 mai 25 14:54 bootx64.efi -rwx------ 1 root root 1334816 mai 8 21:48 BOOTX64.EFI-old -rwx------ 1 root root 1213032 mai 24 23:04 fbx64.efi -rwx------ 1 root root 1269496 mai 24 23:04 mmx64.efi mac2011-linux# ls -l ubuntu total 4183 -rwx------ 1 root root 108 mai 24 23:04 BOOTX64.CSV -rwx------ 1 root root 126 mai 24 23:04 grub.cfg -rwx------ 1 root root 1677176 mai 24 23:04 grubx64.efi -rwx------ 1 root root 1269496 mai 24 23:04 mmx64.efi -rwx------ 1 root root 1334816 mai 24 23:04 shimx64.efi
I don't know if the ubuntu directory is actually read. I know that bootx64.efi is read because it is a copy of grubx64.efi installed by myself and making GRUB targeting internal drive.
Now I have GRUB, I keep it at least until I am more familiar with Linux but I would rather not add rEFInd, to avoid additional mess.
I found this ArchLinux article on GRUB in particular the section for UEFI systems. This gave me the idea to check GRUB install. I did
sudo apt install grub2-common grub-efi-amd64 and again
sudo update-grub and I got a new
/boot/efi/EFI/ubuntu/grub.cfg pointing to the correct partition on internal drive. This fixes cleanly reboot on internal drive.
So it appears that GRUB was not correctly installed on my system. This might be a small defect of the Ubuntu Linux 20.04 distribution.
I still have to check if the external drive Ubuntu Linux also works.