1

I need to boot Windows and two other Linux distors using Grub. So, I have installed Grub on UEFI partition with a dedicated partition for storing the files used by Grub using the following command.

sudo grub-install --efi-directory=/mnt/efi --root-directory=/mnt/grub --bootloader-id=Grub --uefi-secure-boot --target=x86_64-efi /dev/sda

/dev/sda1 mounted on /mnt/efi is my EFI partition, and /dev/sda2 mounted on /mnt/grub is the partition intended for Grub files.

However upon booting Grub is seemingly unable to find the grub.cfg file I placed at /mnt/grub, and shows the default Grub shell. I am able to manually recover my system by typing either configfile /efi/Grub/grub.cfg or configfile (hd0,gpt2)/grub/grub.cfg.

Here are some of my files

$ sudo tree /mnt/efi/EFI
/mnt/efi/EFI
├── Grub
│   ├── BOOTX64.CSV
│   ├── fbx64.efi
│   ├── grub.cfg
│   ├── grubx64.efi
│   ├── mmx64.efi
│   └── shimx64.efi
└── Microsoft
    |...


$ sudo tree /mnt/grub/grub
/mnt/grub/grub
├── fonts
│   └── unicode.pf2
├── grub.cfg
├── grubenv
└── x86_64-efi
    |...

$ sudo cat /mnt/efi/EFI/Grub/grub.cfg
search.fs_uuid 3110d895-a376-484a-8dba-e0475b9a977c root hd0,gpt2
set prefix=($root)'/grub'
configfile $prefix/grub.cfg

$ sudo fdisk -l /dev/sda
Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disklabel type: gpt

Device          Start        End   Sectors   Size Type
/dev/sda1        2048     526335    524288   256M EFI System
/dev/sda2      526336     657407    131072    64M Linux filesystem
/dev/sda3      657408     690175     32768    16M Microsoft reserved
/dev/sda4      690176  563607551 562917376 268.4G Microsoft basic data
/dev/sda5   563607552  697825279 134217728    64G Linux filesystem
/dev/sda6   697825280  966260735 268435456   128G Linux filesystem
/dev/sda7   966260736  983037951  16777216     8G Linux swap
/dev/sda8   983037952 1117254748 134216797    64G Linux filesystem
/dev/sda9  1117255680 1385691135 268435456   128G Linux filesystem
/dev/sda10 1385691136 1402468350  16777215     8G Linux swap

I feel like there is some trivial mistake I am making, but I have spent too much time on this.

Greatcode
  • 11
  • 3
  • What grub did you install. Ubuntu's grubx64.efi has something hard coded that also need /EFI/ubuntu & the files in that folder. – oldfred May 04 '21 at 18:18
  • I used Grub packages included in both Peppermint OS and Gparted Live. Both are Debian based. May the debain package be hardcoded too? – Greatcode May 04 '21 at 19:47
  • Really only know Ubuntu's grub and its issues. – oldfred May 04 '21 at 21:50
  • I have installed just grub to flash drives, but add the --removable parameter to make it complete with /EFI/Boot. But still have to add my own grub.cfg. I used it primarily to make a grub loopmount bootable set of ISO files as a repair flash drive. That uses the external UEFI boot of /EFI/Boot, but most internal UEFI can also use the as a drive or fallback boot entry. – oldfred May 05 '21 at 02:37
  • So you are suggesting to add the --removable option? I might try that. – Greatcode May 05 '21 at 07:20
  • However, the docs say --removable just makes grub put its binaries in /EFI/Boot. This wouldn't help me as I can already succefully run the grub efi binary. – Greatcode May 05 '21 at 08:55

2 Answers2

0

It seems that GRUB loads grub.cfg from the ESP using an absolute path. Perhaps GRUB can't tell which directory it was loaded from.

In the case of Debian that path is /EFI/debian/grub.cfg.

You can use this command to look for paths that a particular .efi executable might be using:

strings /boot/efi/EFI/devuan/grubx64.efi | less '+/EFI\/'

You might need to use a different path from that above to your .efi executable obviously.

This seems to be a related bug.

Copying the grub.cfg to the expected path seems to work:

cd /boot/efi/EFI/
mkdir debian
cp devuan/grub.cfg debian/

Your commands and paths may differ of course. And if grub.cfg changes then the copy will need updating since FAT file systems don't support links. Mine looked like this though, so it looks like it won't change much:

search.fs_uuid $root_fs_uuid root mduuid/$array_uuid 
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg
0

After battling a similar issue yesterday, I was able to find a solution that might help you as well. My /boot is on ext4 and my grub.cfg, like yours, was redirecting the EFI binary to /boot/grub/grub.cfg.

To fix this issue, I manually copied /boot/grub/grub.cfg to /boot/efi/EFI/ubuntu/ instead of using the "configfile" redirect that grub-install adds.

Is it possible that the grub EFI binary is unable to read the grub.cfg on an ext4? Or perhaps it is a path issue as Neil Stockbridge suggested?

EDIT: It might also be helpful to share what I was seeing before making this change. Grub shell was loading and I was able to use commands to launch Ubuntu 22.04, the Grub menu was just not displaying.

Peregrino69
  • 2,337
  • 1
  • 15
  • 22
clinky
  • 1
  • 1