Cannot find EFI directory: issue with grub-install

  • I was trying to rescue GRUB in Linux. I was able to login in the OS following this tutorial:

    I have to upgrade GRUB to fix the problem. However, when I run grub-install, I get an error:

    $ grub-install /dev/sda
    grub-install: error: cannot find EFI directory.

    My file system contains sda4, sda5, and sda6 for the EFI system, Linux swap, and Linux file system respectively.

    I am not very experienced using mount or other commands.

  • When you run grub-install by default it assumes the EFI system is mounted as /boot/efi

    It depends on your distribution where EFI system is mounted and on some distributions it isn't mounted after boot.

    First check if /boot/efi is mounted with

    mount | grep /boot/efi

    If that doesn't work first try the following to see if it is mounted elsewhere.

    mount | grep /dev/[efi device]

    If neither of those work do:

    mount /dev/[efi device] /mnt

    Now run:

    grub-install --efi-directory=[efi dir]
    grub-mkconfig -o /boot/grub/grub.cfg

    where [efi dir] is either /boot/efi or /mnt and [efi device] is the device with the EFI system partition. If you don't know use the command lsblk -o NAME,PARTTYPE,MOUNTPOINT | grep -i "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"

    Thanks, In the `grub-install --efi-directory=/boot/EFI` as i chroot into `/mnt`.

    Maybe stupid Q but I don't have an EFI dir. Where do I get one? I mean it is supposed to contain files, which command can recreate it?

    @LennartRolland If you have a UEFI compatible system then your system drive will be GPT partitioned and contains a "UEFI System partition." usually the first partition and will be of the type EF00. Many distributions will mount this by default as /boot/efi to among other things allow the GRUB boot loader to update its files. If not you'll have to mount it yourself and add it to fstab. You might also have a UEFI system but that is using legacy mode which means your partitions will be msdos type and you won't have a /boot/efi. Weirder configurations exist but that covers the majority of them.

    Your instructions if EFI is not mounted are wrong. See my edit. `mount | grep /dev/sda6` doesn't work. If EFI is not mounted, you have to check the partitions for type.

    @giusti Probably better to just not make specific device name references.

  • Grub rescue mode can be treated as

    set root=(hd0,gpt6)
    set prefix=(hd0,gpt6)/boot/grub
    insmod normal

    Once you login, enter sudo update-grub && sudo grub-install /dev/sda.

    Should the `grub-install` not the done before the `update-grub`?

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM