u/abu-aljoj04

Automating efibootmgr

I am currently utilizing kernel-install to create UKIs and am seeking to automate the efibootmgr process via a script, rather than performing it manually.

By default, kernel-install generates UKI filenames that include versioning, which means that each kernel update results in a new filename. Consequently, EFI boot entries might reference outdated paths unless they are updated. My goal is to integrate with `kernel-install` (during both installation and removal) to manage this automatically.

My primary concern lies with the cleanup process. While creating new entries is straightforward, safely removing obsolete ones presents a challenge. The main difficulty arises from reliably parsing `efibootmgr` output to identify and remove entries associated with older UKIs. The output format does not appear to be designed for scripting and seems prone to fragility.

I am trying to determine the following:

- Is it a sensible approach to use efibootmgr within a kernel-install script, or am I perhaps addressing the issue at an inappropriate level?

- Is parsing efibootmgr output the standard method for this task, or are there more suitable interfaces available?

- How can one ensure that valid entries (e.g., for Windows) are not inadvertently affected while still performing a thorough cleanup?

Any guidance, examples, or cautionary advice would be greatly appreciated.

reddit.com
u/abu-aljoj04 — 3 days ago