Auto updates: grub is broken

Hello,

I use opensuse Microos with transactional updates.

Today I decided to restart my computer to apply these updates. Unfortunately it no longer starts! It gets stuck in GRUB command lines.

How to reinstall GRUB on microos? (I no longer have yast…)

THANKS

I think you can use (as root):

update-bootloader --reinit

Hmm, that may need to be done in a

transactional-update shell

Thanks,

These commands show an error:

transactional update # update-bootloader --reinit
update-bootloader: 2023-10-04 15:55:48 <3> update-bootloader-8172 run_command.338: '/usr/lib/bootloader/grub2-efi/config' failed with exit code 127, output:
<<<<<<<<<<<<<<<<
+ /usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found theme: /boot/grub2/themes/openSUSE/theme.txt
/etc/grub.d/10_linux: line 242: version_find_latest: command not found
>>>>>>>>>>>>>>>>

Is dracut can be a solution ?

This function was removed in current grub2. The files in /etc/grub.d are marked as config,noreplace, so if file was modified (or RPM thinks file was modified) it will not be overwritten. Post full output of

LANG=C LANGUAGE=C ls -l /etc/grub.d

here is the result:

~> LANG=C LANGUAGE=C ls -l /etc/grub.d
total 112
-rwxr-xr-x. 1 root root 11257 Aug 12 19:46 00_header
-rwxr-xr-x. 1 root root   595 Aug  8  2022 01_suse_ro_root
-rwxr-xr-x. 1 root root  1425 Aug 12 19:46 05_crypttab
-rwxr-xr-x. 1 root root  2004 Sep 17 19:36 05_health_check
-rwxr-xr-x. 1 root root 13804 Aug 12 19:46 10_linux
-rwxr-xr-x. 1 root root 18279 Aug 12 19:46 20_linux_xen
-rwxr-xr-x. 1 root root  2362 Aug 12 19:46 20_memtest86+
-rwxr-xr-x. 1 root root 12212 Aug 12 19:46 30_os-prober
-rwxr-xr-x. 1 root root  1386 Aug 12 19:46 30_uefi-firmware
-rwxr-xr-x. 1 root root   722 Sep 22 22:11 35_fwupd
-rwxr-xr-x. 1 root root   214 Aug 12 19:46 40_custom
-rwxr-xr-x. 1 root root   215 Aug 12 19:46 41_custom
-rwxr-xr-x. 1 root root   937 Aug 12 19:46 80_suse_btrfs_snapshot
-rwxr-xr-x. 1 root root  1497 Sep 17 19:36 83_health_check_marker
-rwxr-xr-x. 1 root root  1259 Aug 12 19:46 90_persistent
-rwxr-xr-x. 1 root root   270 Aug 12 19:46 95_textmode
-rw-r--r--. 1 root root   483 Aug 12 19:46 README

What grub2 version do you have? On Tumbleweed I have

-rwxr-xr-x 1 root root 15236 Sep  6 20:52 10_linux

with grub2

bor@tw:~> rpm -q grub2
grub2-2.12~rc1-2.1.x86_64
bor@tw:~> 

Hi I have this version :

rpm -q grub2
grub2-2.12~rc1-2.1.x86_64

Then for whatever reason files in /etc/grub.d were not updated. I do not use MicroOS and am not familiar with its architecture (beyond some basic tests I did) nor do I have it installed, so hopefully someone else can help to troubleshoot it.

I do have MicroOS installed in a VM.

I just updated (ran “zypper dup” in a transactional-update shell), and rebooted. After the reboot, most of the files in “/etc/grub.d” now have Oct 02 dates. So those files are being correctly updated here.

Ok I will try to do this.

Ok I have run the command

transactional-update

but it seems that it cannot make a new grub config:

dracut[I]: *** Creating initramfs image file '/boot/initrd-6.5.4-1-default' done ***
.
update-bootloader: 2023-10-07 06:29:19 <3> update-bootloader-0491 run_command.338: '/usr/lib/bootloader/grub2-efi/config' failed with exit code 127, output:
<<<<<<<<<<<<<<<<
+ /usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found theme: /boot/grub2/themes/openSUSE/theme.txt
/etc/grub.d/10_linux: line 242: version_find_latest: command not found
>>>>>>>>>>>>>>>>
..done]
There are running programs which still use files and libraries deleted or updated by recent upgrades. They should be restarted to benefit from the latest updates. Run 'zypper ps -s' to list these programs.
 
2023-10-07 06:29:20 Application returned with exit status 0.
2023-10-07 06:29:20 Transaction completed.
Trying to rebuild kdump initrd
Creating a new grub2 config
2023-10-07 06:29:20 tukit 4.4.0 started
2023-10-07 06:29:20 Options: call 126 bash -c /usr/sbin/grub2-mkconfig > /boot/grub2/grub.cfg 
2023-10-07 06:29:20 Executing `bash -c /usr/sbin/grub2-mkconfig > /boot/grub2/grub.cfg`:
Generating grub configuration file ...
Found theme: /boot/grub2/themes/openSUSE/theme.txt
/etc/grub.d/10_linux: line 242: version_find_latest: command not found
2023-10-07 06:29:21 Application returned with exit status 127.
2023-10-07 06:29:21 tukit 4.4.0 started
2023-10-07 06:29:21 Options: close 126 
2023-10-07 06:29:21 New default snapshot is #126 (/.snapshots/126/snapshot).

I have the same error:

/etc/grub.d/10_linux: line 242: version_find_latest: command not found

Is your system now up to date? Do most of the files in “/etc/grub.d” have October dates?

There is something weird about how transaction-update is handling this.

When I updated the grub2 package on a Tumbleweed system, those files were updated with the installing of the new version (before some of the other updates had been installed).

But when I did that with my MicroOS system, those files were not immediately updated. They did not show as updated until after I rebooted.

If one of those files was old enough to cause errors, then it looks as if the update would have used the old files to try to regenerate grub.cfg, and would still give errors until after a reboot and another attempt to update grub.cfg.

How can I regenerate grub.cfg ?

update-bootloader --reinit

Is not working…

Was not it clear already that you first need to make sure all grub2 files are updated to match your installed version? Try to force reinstall grub2 package. Check that the content of /etc/grub.d is up to date.

I just tried this as an experiment – details below.

First, I cloned my MicroOS vm, and worked with that clone for testing.

(1) I made sure I had a way of booting the system that did not depend on grub working. In this case, I had Tumbleweed on an external USB drive, so I booted that drive in my cloned VM. I then updated grub2 there, so that the boot menu for the external drive included an entry to boot MicroOS.

(2) I tested this alternative way of booting (it worked)

(3) I booted into the cloned VM the usual way. I then ran (as root)

transactional-update pkg remove grub2

That removed several packages. (I should have written down what they were, but I didn’t)

(4) I rebooted. And, as expected, I got a grub failure on boot.

(5) I rebooted using my alternative way of booting. And then I ran:

transactional-update pkg install  grub2-x86_64-efi

which pulled in several other grub packages.

(6) I now rebooted the normal way. And this worked. However, I noticed that booting from a snapshot was no longer in the boot menu.

I later checked my original (not the clone) MicroOS VM, and found that “patterns-base-bootloader” was one of the other packages removed. So I installed that again. And I restored the original “/etc/default/grub” (from “/etc/default/grub.rpmsave”). In a transaction-update shell, I then ran “update-bootloader” but I still do not have a menu item to boot a read-only snapshot.

You can maybe try something similar. It should get you back to a working grub. But I’m unsure how to restore the boot entry to boot a snapshot.

I repeated this, with some changes.

I deleted my previous cloned virtual machine.

Next, I made another clone.

I booted that clone, logged in, and ran (as root):

transactional-update shell

Within that transactional-update shell, I did:

zypper rm grub2
zypper install patterns-base-bootloader
cd /etc/default
mv  grub.rpmsave grub
update-bootloader

I then rebooted. It booted normally, and the grub menu item to boot a read-only snapshot was still there.