Pacman Hooks in View of Recent Changes to GRUB

To reflect on these two quoted sentences, I have played around today on my EnOS Bios (legacy) installation, and created two pacman-hooks, that some here might find helpful…

Note to Newbies, ready to experiment:
Pacman hooks are simple text-files, placed inside the folder /etc/pacman.d/hooks/ .
The suffix (filename-extension) must always be “.hook” for each file, to be carried out automtically by the system (not by the user).

See my grub-mkconfig.hook:

Summary

[Trigger]
Operation = Install
Operation = Remove
Type = File
Target = usr/lib/modules/*/vmlinuz

[Action]
Description = Updating GRUB-configuration after changes to kernels installed…
Depends = grub
When = PostTransaction
Exec = /usr/bin/grub-mkconfig -o /boot/grub/grub.cfg

See my grub-install.hook
(works only for bios/legacy-systems with
/dev/sda as main system drive):

Summary

[Trigger]
Operation = Install
Operation = Upgrade
Type = File
Target = usr/lib/grub//.mod

[Action]
Description = Installing GRUB after grub-update…
Depends = grub
When = PostTransaction
Exec = /usr/bin/grub-install --target=i386 /dev/sda

As I am not in possession of any EFI (UEFI) -enabled computer, I cannot test possible solutions on my own for this. Also, there probably will be a lot of different solutions necessary for these systems, depending on their individual setup.

Perhaps, some here like to share their pacman-hooks to re-install GRUB on an EFI system, alongside presenting their individual solutions, as needed?

3 Likes

I just want to point out that as far as I know, there is no generic way to call grub-install that will work for all UEFI installs. Just calling grub-install --no-nvram with no additional arguments will probably work for most installs. The problem is that it also has the ability break your install depending on your specific configuration.

For hooks for grub-mkconfig there is a package in AUR called grub-hook which provides the hooks you need for that.

3 Likes

I am aware of that, and I mentioned it in my OP. Also, the AUR-package for grub-mkconfig is in the quote of @Bryanpwo which I gave in full.

My intentions for this OP were to get more folks to start getting more self-sufficient by experimenting with such things on their own,…

…and the second reason is, I asked for users’ individual solutions, because we all could learn from each other this way. :wink:

In that case, I might point out that I am not sure you need to run grub-mkconfig on Upgrade. In theory you should only need to run it on Install and Remove

1 Like

Me neither. It is why I left it in, just to be sure to omit nothing potentially necessary.

Correct.

2 Likes

Is that afffirmative? - It couldn’t hurt to leave it in, or?!

If you leave it in, it will run grub-mkconfig more than you need to.

Ok, so I’ll take it out then. You two convinced me! :laughing:

Done!

Ok. So today I learned the hard way…

After installing the hooks I provided above, an EnOS kernel-update shot my dual-boot with Arch Linux to death.

What happened? - Well, I wasn’t really aware, that EnOs, other than Arch Linux, has another - very important hook installed:
90-mkinitcpio-install.hook

So everyone, please all disregard my OP as a potentially good suggestion!!!

When copying those files I gave above to /etc/pacman.d/hooks/ it will lead to a situation that 90-mkinitcpio-install.hook will not be carried out on kernel updates and thus render the system un-bootable.

Just saying…