Grub 2:2.06.r322.gd9b4638c5-1 won't boot and goes straight to the BIOS after update

OK.
Really thank you @pebcak for your support.
Hope to hear from @dalto and hope he approves my script and my way of thinking to be sure Grub won’t break if I missed something (though it is not perfect I know… it needs an if statement to run or not run the last 2 commands. But I do not really know how to check through an “if”)

For the grub stuff, first you must make sure which options the grub-install command requires in your system. If you know what it takes, then add the grub-install and grub-mkconfig with proper options to the script.

Otherwise don’t add grub stuff in the update script.

Then, the update script could be e.g. like this:

yay --needed -Sy archlinux-keyring endeavouros-keyring
yay -Su
sync

The first line updates the package database and keyring packages if needed.
The second line updates both repo and AUR packages.
The third line flushes the filesystem cache.

This should cover most obvious caveats. In addition to this, the script could make various useful checks, for example

  • available disk space
  • pacman database lock file
  • some Nvidia driver checks if you have an Nvidia GPU

and more.

1 Like

Oooops! There is no standard/default grub-install that just works?!
(Sorry, I repeat again hoping you forgive my illiteracy, I am just a user, not techie by any means)

Doesn’t all this get done by default by issuing the command yay?
While updating my system I never did anything more than just yay -Syu

Am I missing something with my system and should run these commands?

P.S. I am thinking of doing this if it is OK and ensures Grub updates will run smoothly and won’t break with updates.

systemd-boot is part of systemd. You don’t need to remove it. If you installed one of my kernel-install packages, you should remove that.

The sequence would look like this:

  • Remove kernel-install-mkinitcpio or kernel-install-for-dracut
  • Install and configure grub
  • Once grub is working clean-up the leftover systemd-boot stuff from your ESP

The command yay --needed -Sy archlinux-keyring endeavouros-keyring is important for people who update infrequently. I would only recommend taking this approach if you don’t update often or you get a keyring error. For example, some of my VMs go months at a time without getting updated. They almost always need the archlinux-keyring package updated before an update.

In a normal situation, just typing yay is all you need.

As for calling an explicit sync, I don’t really understand what the real world scenario where this would be needed is.

1 Like

Correct. However there’s a chance that plain grub-install without options just works. See more here: https://wiki.archlinux.org/title/GRUB
Please note that it is up to you to find out which options are needed, if any.

Not entirely. Note the first line updates keyrings first. This is often required when the keys change. Another addition is the call to sync, as a precaution to make sure files actually are saved on the disk instead of just the cache.

Your system, your rules.

Those 3 lines do not guarantee anything about grub. As said above, you must find out the options for grub-install for your system.

2 Likes

Thanks a lot @dalto for the rescue as usual.
So, following what you said and Arch Wiki I will exactly do:

yay -Rc kernel-install-mkinitcpio
sudo grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg

I can then reboot to Grub.
Then I will create the script sysupdate.sh as follows - to update the system and be sure all the Grub things will be done if it is updated:

yay
sudo grub-install
sudo grub-mkconfig -o /boot/grub/grub.cfg

I just want to be sure:
1- Installation steps are correct
2- the script will work and update system as usual and reinstall grub if needed after an update to Grub.

I just want to be sure I won’t brick the system.
I hope I am right this time (at least mostly)

I really appreciate your generous support and patience.

You need to replace esp with the path to your ESP. It is probably either /efi or /boot/efi

Uhh…no. Don’t reinstall grub everytime you update. Do it only when grub is updated.

Sure I understand. We are talking about software anyway.
But at least I do not need to bother to do the installation over and over with every update to Grub.

It will be installed/reinstalled through the script, something similar to what we had before this Grub issue.
I just make a command of my script and just call it and it does everything.

I know it is not really needed every time I update! I am putting them just in case I am not really focusing or made a mistake if there is a Grub update.

It is an extra unneeded step I know. Would it hurt?

I wish I know a way to put an “if” statement in the script. If Grub in particular updated then do the 2 commands.

It could. Reinstalling your bootloader isn’t a riskless operation.

Don’t use a script, use a pacman hook, that is what they are for.

You might want to consider the following for grub. Note that it adds no options to grub-install, so you must make sure what is correct for you.

And, I didn’t test this, so it may contain bugs. :wink:

previous_version=$(pacman -Q grub)
yay
current_version=$(pacman -Q grub)

if [ "$previous_version" != "$current_version" ] ; then
    grub-install
    grub-mkconfig -o /boot/grub/grub.cfg
fi
1 Like

I will appreciate giving me a hint. I am reading all the time about “hooks” but know nothing about them!

“Hooks” will let the Grub install automagically if there is an update as before?

It allows you run to a command in certain circumstances. In this case, the condition is “grub is updated”

Also, there are already hooks for grub-mkconfig in AUR. You can just install them. Then you only need to handle grub-install

As far as I understand, in my case at least where I update regularly no options needed.

If your ESP is mounted somewhere other then /boot/efi you will need to specify --efi-directory=/path/to/efi

I would call you a genius if you could put bugs in those few lines :rofl:

I tried, and seems working and logical

[limo@lenovo ~]$ x=$(pacman -Q kate)
[limo@lenovo ~]$ echo $x
kate 22.08.1-1
[limo@lenovo ~]$ 

So, to save myself - for now - some time till I “study” hooks and practice with them.

I hope @dalto would approve (will write the script soon below)
Oh, @manuel already got it

I might just add sudo before the 2 commands. Right?

May I ask why? A script will do as if I am doing it manually.
What is the difference between script and hooks?
I am just trying to learn not arguing of course.

A hook for grub will be executed automatically when you update the system (and grub updates) with e.g. yay.

1 Like

The hooks will always work. The script requires you to call it explicitly.

They will work if:

  • You don’t call your script
  • No matter which wrapper/package management tool you use.
    • You can pacman, yay, paru, pamac, octopi, pacseek, etc, etc. The hook will always get called.
1 Like

This really sounds amazing and interesting.
This is the way to go then.

So, I actually “hook” the grub re-installation as I was trying to do to the condition that there is a Grub update. If there is no Grub update they won’t run!

I will appreciate giving me a hint or a link on how to … you call it create a hook?

I would recommend getting grub installed and configured first. Then you can manage the automation of updating afterwards.

Also, if you install the package grub-hook, you can look at that simple hook as an example.

The documentation is here:
https://man.archlinux.org/man/alpm-hooks.5