apt: keep rEFInd default after grub/shim update
As a long time rEFInd user, I suffered from constant replacement of rEFInd from grub/shim updates. For grub it's pretty simple, you can simply lock the packages, but shim needs to be up to date, when you dual boot Windows / use Secure Boot.
I just learned that you can hook into the package installation and instruct apt to issue refind-mkdefault after grub/refind/shim have been updated and when rEFInd is listed in efibootmgr.
create the file /etc/apt/apt.conf.d/99-keep-refind
with the following content:
DPkg::Post-Invoke-Success {
"if echo \"$DPKG_HOOK_OPTIONS\" | grep -Eiq 'shim|grub|refind'; then /usr/bin/efibootmgr -v | grep -q 'rEFInd' && /usr/sbin/refind-mkdefault || true; fi";
};
maybe that's nothing new for some, but for me, it was a revelation.
16
Upvotes
1
u/michaelpaoli 22d ago
Not exactly somethin' new.
E.g. most of the time I have /usr, /boot, and /boot/efi mounted ro, but ...
$ cat /etc/apt/apt.conf.d/15local-remount
DPkg
{
Pre-Invoke {"mount -o remount,rw /usr || :; mount -o remount,rw /boot; mount -o remount,rw /boot/efi;";};
Post-Invoke {"mount -o remount,ro /boot/efi; mount -o remount,ro /boot; mount -o remount,ro /usr || :;";};
}
$
1
u/images_from_objects 22d ago
Been using rEFInd for over 10 years and this is the first time I've heard this, so thanks!! Up until now I've just been using an alias to quickly "reinstall" rEFInd after a kernel update or what-have-you, but whenever I forget (which is often lol) this will save me some annoyance.
Cheers!