Grub Breakage ... Again!

I’m sorry to raise this again, but things happen.

I just installed EndeavourOS on a very old machine, like 10 years old or more.
During installation I did not have sytemd-boot as default, I had only Grub, so I had no option.

As you may remember or find here I have bootloader hopped between systemd-boot and Grub several times, several installations… etc till I settled finally on systemd-boot.

During my boot loader hopping, with the help and guidance of our friends here I could make “hook” that looks after the issue of Grub breaking and not booting the system by automatically reinstalling it if needed. (you may check Grub Hook to grub-install and grub-mkconfig?)

Now as per the discussion that was going at No grub menu at start our friend @Gamall gave us a link to Latest grub bricked my system (grub_is_shim_lock_enabled not found)

I understood from the OP @gipo355 that he did the Grub install and… waht is required so not to have unbootable system but still it happened and with some others as well.

So, I am worried that the hook I made (at Grub Hook to grub-install and grub-mkconfig?) which I just saved on this old laptop might not work!

I wonder how can I be sure it won’t happen to me. I can’t tolerate even thinking there is a possibility I end up with unbootable system.

Now my question(s):

  • is there a way hopefully to improve the hook to avoid Grub problems? A script perhaps that runs automatically?
  • is there a way to convert to systemd-boot (though I doubt my machine would support as it was not available during installation.

Here is my inxi -Fxxx: https://pastebin.com/mhcBAmuG

I got 2 text files containing my BIOS data (name reflects command)

  • Biosdmdecode.txt
  • biosdecode.txt

in case anything needed from them.

I tell you what, feel free to simply ignore the question, I am just curious, I am using this laptop for backup purpose and as a personal cloud storage, and I do not mind doing another fresh install if needed.

I honestly don’t know why you are going through this all the time? I use grub on all my systems. Some dual boot, some with nvidia some with btrfs. Have i had grub break? Only on a few occasions. Sometimes it happens when updating UEFI firmware because it wipes out the nvram entries. It happens! Not every time but it has on occasion. It’s not like I’m updating the UEFI firmware that often but whenever there are newer updates I always update it. This has required me to arch-chroot and reinstall grub and run the update grub command to get the entry back in order to boot from the drive that EndeavourOS is installed. Other than that i have only run into it when the original grub fiasco happened and that was a matter of timing. It didn’t happen on all my systems because it depended on when i did the updates and once i became aware there was an issue i knew there would be manual intervention in order to deal with that situation. Other than that i rarely have any issues with grub or updating. Updates install and the systems work. I don’t do anything, i don’t change anything. I just use endeavourOS as it is installed.

Currently i am using Wayland both on Nvidia hardware and amdgpu with btrfs and the Nvidia system is dual boot Win 11. They are both on KDE Plasma and they work so well i will never change to any other desktop or stop using grub.

4 Likes

Since I settled on systemd-boot I don’t care. But I found myself having no other option. So, I am just curious, other people asked almost the same as in the thread in my OP!

So, I will take this as the answer to my question!
Thanks

Create a file /etc/pacman.d/hooks/grubfix.hook

sudo nano /etc/pacman.d/hooks/grubfix.hook

Add the following lines:

[Trigger]
Operation = Upgrade
Type = Package
Target = grub

[Action]
Description = Reinstall grub when it updates…
When = PostTransaction
Exec = /bin/sh -c “/usr/local/bin/grubfix.sh”

Then create the grubfix.sh script and place it in /usr/local/bin/ and make it executable.

sudo nano /usr/local/bin/grubfix.sh

Add the following lines for a UEFI intstalled system:

#!/bin/bash
grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=endeavouros --recheck
grub-mkconfig -o /boot/grub/grub.cfg

Make sure to adjust the --efi-directory=/efi setting to where the efi partition is mounted and the --bootloader-id=endeavouros setting to what EndeavourOS actually uses.

Or, for a legacy BIOS system:

#!/bin/bash
grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

Make sure to adjust the grub-install --target=i386-pc /dev/sda setting to the drive grub is actually installed to.

Remember to mark the grubfix.sh script executable:

sudo chmod +x /usr/local/bin/grubfix.sh

The hook and the script will reinstall grub to your disk whenever the package is updated.

2 Likes

I don’t know if it’s an answer to your question? I’m just pointing out that grub issues shouldn’t be that prevalent. They do happen but they shouldn’t be happening on the basis that i see in this forum. I don’t know much about hooks and writing scripts and all that stuff. I leave that to the people who know what they are doing and have more knowledge than i do i that regard. The hook you are using if i recall was to run the grub update command? I’m not sure how you have it set up to work but i can say that i do use the update grub command when necessary. That is if i add something to the grub command line such as a kernel parameter or if there is a new grub version package. In that case i would reinstall grub and run the update grub command.

Edit: I’m no expert and i just do what i think is correct and what works for me.

I really thank you @eznix for caring to reply.

I already have a hook that sometime ago when I was on Grub that was fine. It reads as follows:

[Trigger]
Operation = Install
Operation = Upgrade

Type = Package
Target = grub

[Action]
Description = Re-generate Grub if Updated
When = PostTransaction
Depends = grub
Exec = /bin/sh -c "/usr/bin/grub-install && /usr/bin/grub-mkconfig -o /boot/grub/grub.cfg"

I believe it does the same as your reply or am I missing something? Sorry, I am no techie!

It does install Grub if needed I assume.
Why I made this thread initially is that I noticed in the other thread at Latest grub bricked my system (grub_is_shim_lock_enabled not found) OP said he installed Grub after the update which was supposed to make him avoid problems. But t happened though.

This is where my question comes from and why my question came up to my mind. It is about learning, curiosity that maybe a waste of time!

I prefer to run a more explicit grub-install command such as:

grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=endeavouros --recheck

or:

grub-install --target=i386-pc /dev/sda

Depending on whether the system is UEFI or BIOS.

Call it a bit of OCD, but I feel better telling grub-install exactly what to do and how when invoked rather than let it pick up the environment settings from the system.

2 Likes

You are right, It shouldn’t be prevalent, but when it happens users ask! They need help!

But for me

I said at the end of my post what means I don’t care

So, it was just

you mean explicitly specifying where to install?
Shouldn’t it default to /dev/sda or wherever as it is supposed to be installed by default to the default location?
(as I searched I guess my system is BIOS as there is no folder /sys/firmware/efi/

So, I assume you suggest I change:

Exec = /bin/sh -c "/usr/bin/grub-install && /usr/bin/grub-mkconfig -o /boot/grub/grub.cfg"

to be

Exec = /bin/sh -c "/usr/bin/grub-install --target=i386-pc /dev/sda&& /usr/bin/grub-mkconfig -o /boot/grub/grub.cfg"

It should, but why guess? :slight_smile: I like to specify. I also feel safer putting those commands in a separate script and letting the hook run the script to do the actual work. Maybe that’s just more OCD for me? :rofl:

1 Like

The installer don’t propose systemd-boot if you are not using a UEFI system. Did you check in your bios if you can change that ?

I see, you are a very precise perfectionist!

Again, the naughty curious me, I can’t skip or ignore to ask, what is the difference? Both are software, both will run the same command!

The answer to this is the answer to my question above, what’s the difference. I am sure you have a reason or a logic behind this which I am curious to know.

So to summarize, may I ask you @eznix do you see that my hook should work as expected?
Still remains the question, if it works as expected and installs Grub if needed which the OP at Latest grub bricked my system (grub_is_shim_lock_enabled not found) said he did then the question why did it break with him!

I’m sorry, I am always asking, since I was a kid, whatever I sense with any of my senses I ask!

By the way, asking was what guided me to Linux, way back at the beginning of 2000 after suffering a lot of :poop: of M$, I asked many questions:

  • How come can banks work with this :poop: how do they make money and keep their clients money
  • How come factories work with this :poop: and make money
  • If airports… how planes do not crash every 10 minutes!
  • Can ministries of defense, air defense… work with this they will be vulnerable if their oponent just used pencil and paper
  • How could…
  • are there other operating systems that are reliable
  • what are they
  • why are they more reliable
  • can I get any of them
  • how…
    .
    .

You see a system crashing made me ask 10 questions to start with, with every answer creating more questions…

Sorry, this is me. Sorry, isn’t this how humanity developed and is developing!
This is how I developed myself personally.
I apologize

I remember some time ago I believe @dalto asked me to change a certain setting in BIOS to have it, I searched that old reply to me, but for some reason the same that worked before made the machine unable to read USB, so I couldn’t install. So I just went with defaults.
But I don’t mind trying again

If your hook works for you, then that’s all you need to answer your question. I actually use a more complicated grubfix.sh type script that tests for UEFI or BIOS, tests for NVME vs SATA disk type and runs the appropriate command depending on the results. Since my script does a bit more than just run the grub-install, it was necessary to make the hook run a script.

OK, so that user did this:
grub-install ...
That is the example from the output of pacman after grub is updated. That is meant to indicate that grub-install should be run with the correct settings for your system. The “…” means to follow the grub-install command with whatever settings are appropriate for your use case. The OP of that thread did not know that and messed up their system.

1 Like

Has nothing to do with the dots. I launched the command from home and … In zsh is a shorthand for 2 folders up.

Which means I just run grub-install from /.

Endeavouros has default flags for grub install so you can just run grub install

Dots had nothing to do with the bricking

I see, you are incredibly a perfectionist.
I never thought I would meet someone like you.

This one perfect answer, has a reason, has logic! :+1:

Another reasonable and logical answer. :+1:

I really appreciate the conversation with you, I learned a lot.

I saw in the other thread some friends talking about putting Grub on the ignore list so it does not get updated.

I wonder:

  • is this really OK?
  • Can a user put it on the ignore list forever, or he “must” update/upgrade it occasionally? How frequently?
    -can he update/upgrade manually though it is still on the ignore list? How to?

So it has everything to do with the dots…
Arch’s pacman messages do not assume one is running EndeavourOS or zsh, The … means what it means for all Arch based systems and specifying the options for grub-install is never a bad idea. It may not be necessary on EndeavourOS, but pacman does not know that. :rofl:

1 Like

I would never put a core system component on the ignore list. I certainly would not keep it there for any longer than one upgrade.

1 Like

This is why I asked, I am no techie but it is simple logic.

So, perhaps it can be a good idea to put it on the ignore list, so updates won’t cause a problem, when I find people updated with no problem I can update then put it back on ignore and so on!

That might work for many packages, but grub is special in that the package will update, but that does not mean the grub version on the boot sector is updated. Grub is different in that way from most packages. When the grub package is upgraded, it should be reinstalled to the boot device, to be safe, every time. Most distros do this by default. Arch is more manual and puts that responsibility on the user.

1 Like