You are not logged in.

#1 2022-09-04 10:33:01

jordaniza
Member
Registered: 2022-09-01
Posts: 12

Cannot add boot entry to efibootmgr with grub-install

Edit: Laptop is booting again. Following recommendations from the S76 team, I cleared my NVRAM by disconnecting and reconnecting the CMOS battery, this allowed me to boot into Pop!_OS. Not sure if this has addressed my issues with adding boot entries but the factory reset at least gives me a working system.

Link for system76 users: https://tech-docs.system76.com/models/o … os-battery


Hi,

I've had an issue with booting from my laptop because efibootmgr is consistently failing to register a new entry with grub-install. I need help determining next steps.

Laptop is a System76 Oryx Pro 2021 Model

Background:

I posted earlier this week regarding some issues with grub-install. My laptop wouldn't start after an update but booted from a removable USB just fine. I am trying now to re-add grub to my boot menu on the BIOS settings, but am having no joy.

Long story short, I backed up all my files onto an external HDD and decided to wipe the SSD and start fresh with a clean archinstall - formatted SDD.

I've done the arch install successfully a couple times and was able to replicate a working setup. I've partitioned the drives, setup LVM, installed the kernel on the root logical volume, mounted the EFI partition and attempted to install grub:


The error:

# on the live ISO
mount /dev/volgroup0/lv_root /mnt
mount /dev/nvme0n1p1 /mnt/boot/EFI
arch chroot /mnt

grub-install --target=x86_64-efi --bootloader-id=grub_uefi --recheck

I am able to install grub with no problems by adding the --remote flag. Previously this allowed me to boot the full system when the USB was installed, but I obviously would prefer to have the laptop boot into grub from BIOS, then arch from grub

Running grub-install in --debug gives me:

grub-install: info: executing efibootmgr -c -d /dev/nvme0n1 -p 1 -w -L grub_uefi -l \EFI\grub_uefi\grubx64.efi
Could not prepare Boot variable: Input/Output error

# Sometimes this will fail with Block Device Required

Then looking at the output of efibootmgr -v

BootOrder 0003,0001,0000,0004
Boot0000* Linux Boot Manager ...
Boot0001* UiApp MemoryMapped ...
Boot0002 Could not parse device path: No such file or directory
Boot0003* Pop!_OS 21.10 ...
Boot0004* SanDisk Ultra ...

Note: None of the entries other than SanDisk (my external USB drive) actually work. I will also say that in my previous working arch install, they did not work. There was a grub_uefi entry in Boot0002 which successfully booted into Grub where I had Linux and Linux LTS installed.

Running grub install multiple times will add "Could not parse device path: No such file or directory" to subsequent boot entries (Boot0005 etc etc), which can be removed with:

efibootmgr -b {bootloader entry} -B

My fdisk -l

Disk /dev/nvme0n1 ...
...
Disklabel type: gpt
...
Device
/dev/nvme0n1p1 512M EFI System
/dev/nvme0n1p2 512M Linux LVM

From what I can see then, for some reason, I am not able to properly install the bootloader as an EFI entry. At this point I've searched fairly extensively and am struggling to find next steps to investigate. I am also concerned that messing around too much with the EFI settings seems like a bad way to go.

Would welcome comments and suggestions here

Last edited by jordaniza (2022-09-10 19:26:42)

Offline

#2 2022-09-04 13:09:15

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Cannot add boot entry to efibootmgr with grub-install

jordaniza wrote:
grub-install --target=x86_64-efi --bootloader-id=grub_uefi --recheck

You're not specifying the location of your ESP directory in the grub-install command. Read...
https://wiki.archlinux.org/title/GRUB#Installation


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2022-09-04 13:20:48

jordaniza
Member
Registered: 2022-09-01
Posts: 12

Re: Cannot add boot entry to efibootmgr with grub-install

Running

grub-install --target=x86_64-efi --bootloader-id=grub_uefi --esp-directory=/boot/EFI --recheck

Gives me the same issue:

grub-install: error: efibootmgr failed to register the boot entry: Input/Output error.

I have checked that I am in UEFI mode:

 
ls /sys/firmware/efi/efivars

Produces a list of EFI Variables

I have also checked and when launching the ISO, the entry specifically says "Arch Linux...UEFI"

I'm currently reading about the general efibootmgr and boot process. My concern is that, if this is an issue with NVRAM (which would make sense given that the --no-nvram flag) seems to work, then I'm wondering if this is a firmware thing?

Offline

#4 2022-09-04 14:18:51

jordaniza
Member
Registered: 2022-09-01
Posts: 12

Re: Cannot add boot entry to efibootmgr with grub-install

Something to add:

grub-install is successfully copying files into my ESP. However, efibootmgr is failing to create the boot entry. I ran the offending command directly

efibootmgr -c -d /dev/nvme0n1 -p 1 -w -L GRUB -l \EFI\GRUB\grubx64.efi -v

The specific error is:

efivarfs_set_variable(): writing to fd 4 failed: Input/Output error
efivarfs_set_variable(): failed to unlink /sys/firmware/efi/efivars/Boot000X-XXXXXXXXXXXXXX: invalid argument
efibootmgr.c make_var(): efi_set_variable failed: Input/Output error
efibootmgr.c make_var(): Could not set variable Boot000X: Input/output error

Offline

#5 2022-09-04 16:32:02

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,178

Re: Cannot add boot entry to efibootmgr with grub-install

Have you seen https://github.com/system76/firmware-open/issues/153? Especially https://github.com/system76/firmware-op … -778448050. That sounds pretty weird to me.  I'm really surprised if that comment is really how it is designed to work.

But try copying the grub EFi to \EFI\BOOT\BOOTX64.EFI and then try adding the boot entry. Even if you can't add the boot entry, you may be able to still boot to grub without the USB as that is a fallback location which the firmware may look for if it can't find a working boot entry. This sometimes works even on finicky and buggy firmware.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#6 2022-09-05 13:37:44

jordaniza
Member
Registered: 2022-09-01
Posts: 12

Re: Cannot add boot entry to efibootmgr with grub-install

After a full weekend of frustration, I am still without a working machine. I even did a fresh install with a Pop!_OS USB, given that as a system76 laptop this would have the best chance of showing me if this was a partitioning or setup issue.

Pop!_OS fails in the same place: efibootmgr cannot write the new boot entries so I am now confident this is not to do with my disk setup.

My next steps:

Changing the EFI directory and mount point does not seem to fix the issue but after looking at @cfs's suggestion and reading Rod Smith's EFI book I am going to attempt to install grub with --removable and try and boot through the fallback bootloader.

I don't think I've been doing this until now because I've been cycling through boot options until I hit the USB, I also think I need to include the /boot/EFI directory in my fstab as currently is is only mounting the LVM volumes for root and /home.

If that doesn't work I am going to explore different bootloader options. I'm skeptical about these as efibootmgr is the clear place where the boot is failing, and I believe it is a common denominator across systemd-boot, GRUB and others.

Another option I have is to reinstall some of the system76 firmware, I have reached out to their support team to discuss how to factory reset my machine if it is, in fact a firmware issue blocking the NVRAM from accepting new boot entries. I have heard from a couple of folks that firmware upgrades helped them, but this is obviously a bit of shot in the dark and I would rather update the firmware from a working distribution.

A final option I want to explore is using the EFI Shell to add a boot entry. I'll probably practice on a VM a couple of times to get the hang of this as I have now sourced a backup machine and have all my old files safe, so I'm no longer in a rush to get this fixed.

I hope the above is helpful to anyone else in my position and will report back here if things are sorted.

Last edited by jordaniza (2022-09-05 13:38:55)

Offline

Board footer

Powered by FluxBB