This machine is a generic modern AMD64 laptop with Intel Core i7, UEFI, and internal NVMe storage.
I have installed Elementary OS with a bootable USB flash drive (burned from the ISO) on my portable disk (WD 2TB 2.5-inch). This is the only USB storage device during my boot time so I will call it "sda" in the following paragraphs.
I have 7 partitions on
sda. Partition sda5 is the installation root for Elementary OS; sda6 is the ESP; sda7 is a previously installed Ubuntu.
During installation, I selected sda6 as the ESP. It turned out that the directory
sda6/EFI/Elementary\ OS does exist and the desired
.efi files are perfectly located there.
I checked efivarsfs, the boot entry for Elementary OS does appear as Boot0002.
Boot0002* Elementary OS HD(6,GPT,13e6d075-53e2-41b9-bdd4-c19f7b6eb970,0xe66e8800,0x100800)/File(\EFI\Elementary OS\shimx64.efi)
During boot, I selected the UEFI boot entry for Elementary OS, and Grub boot menu appeared. In the list, there is no Grub boot entry for "Elementary OS".
I checked sda5/boot/grub/grub.cfg and noticed that the
menuentry lines did include the entries for Elementary OS and the kernel parameters are perfectly correct (root=UUID=... ro quiet splash).
I rebooted with the same UEFI boot entry and pressed "C" key to enter Grub shell. With
echo $root, I figured out that the $root variable was set to
hd0,gpt7, the partition for Ubuntu instead of the one for Elementary OS. Doubtlessly, the $prefix variable was set to
(hd0,gpt7)/boot/grub. I manually executed
configfile (hd0,gpt5)/boot/grub/grub.cfg, then a new Grub menu appeared, which included the Grub boot entries for Elementary OS (basic and advanced options).
As I booted into Elementary OS with this manual operation, I manually executed:
$ grub-install --target=x86_64-efi --bootloader-id="Elementary OS" --efi-directory=/boot/efi $ grub-mkconfig -o /boot/grub/grub.cfg
And I rebooted and things do not change. The expected Grub boot entries do not appear in the menu.
I suspect that something might worked wrong during