Bug 1899903 - grub2-mkconfig is never run on kernel upgrade even if GRUB_ENABLE_BLSCFG=false
Summary: grub2-mkconfig is never run on kernel upgrade even if GRUB_ENABLE_BLSCFG=false
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: grub2
Version: 8.2
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: rc
: 8.0
Assignee: Bootloader engineering team
QA Contact: Release Test Team
URL:
Whiteboard:
Depends On:
Blocks: 2018331
TreeView+ depends on / blocked
 
Reported: 2020-11-20 10:59 UTC by Welterlen Benoit
Modified: 2022-05-10 16:57 UTC (History)
11 users (show)

Fixed In Version: grub2-2.02-118.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2018331 (view as bug list)
Environment:
Last Closed: 2022-05-10 15:31:42 UTC
Type: Bug
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RTT-4191 0 None None None 2022-02-02 18:42:26 UTC
Red Hat Issue Tracker RTT-4192 0 None None None 2022-02-02 18:42:32 UTC
Red Hat Issue Tracker RTT-4260 0 None None None 2022-02-21 11:42:27 UTC
Red Hat Issue Tracker RTT-4261 0 None None None 2022-02-21 11:42:35 UTC
Red Hat Product Errata RHSA-2022:2110 0 None None None 2022-05-10 15:32:26 UTC

Description Welterlen Benoit 2020-11-20 10:59:55 UTC
Description of problem:
- if GRUB_ENABLE_BLSCFG is disabled in /etc/default/grub and "grub2-mkconfig -o /boot/grub/grub.cfg" is run once, grub.cfg is never refreshed on kernel upgrade and the new kernel is not available on grub menu, even if we reenable GRUB_ENABLE_BLSCFG

Version-Release number of selected component (if applicable):
grub2-common-2.02-81.el8.noarch

How reproducible:
Always

Steps to Reproduce:
1. disable GRUB_ENABLE_BLSCFG in /etc/default/grub.
2. run once grub2-mkconfig -o /boot/grub/grub.cfg
3. next kernel upgrade, grub.cfg is not updated, even if GRUB_ENABLE_BLSCFG is enabled

Actual results:
- grub.cfg not updated on kernel install

Expected results:
- grub.cfg update with last kernel 

Additional info:
- Of course, the best is to use BLS, but I think many customer still rely on grub2-mkconfig and legacy use of grub.cfg. 
And especially if GRUB_ENABLE_BLSCFG is disabled in grub, grub2-mkconfig should be run on kernel install.

- This is done in /usr/lib/kernel/install.d/99-grub-mkconfig.install when ARCH = ppc64 or ppc64le because there are not BLS capable:
---
if [[ $ARCH != "ppc64" && $ARCH != "ppc64le" ]]; then
---

- A test should be done on /boot/grub/grub.cfg to check if GRUB_ENABLE_BLSCFG is false

I found a BZ on fedora for Xen DomU: https://bugzilla.redhat.com/show_bug.cgi?id=1703700
And now the code is:
---
if [[ $HV_TYPE = "xen" && $XEN_DOM0 != "true" ]]; then
    RUN_MKCONFIG=true
    if grep -q '^GRUB_ENABLE_BLSCFG="*true"*\s*$' /etc/default/grub; then
        sed -i 's/^GRUB_ENABLE_BLSCFG=.*/GRUB_ENABLE_BLSCFG=false/' /etc/default/grub
    fi
fi
---

=> the variable GRUB_ENABLE_BLSCFG is tested but only in case of XEN

Why grub2-mkconfig is not called everytime when GRUB_ENABLE_BLSCFG=false ?

Comment 1 Alberto Chiodi 2020-11-26 08:35:30 UTC
I post my problem here because it is similar even though I am a fedora 33 (new)user. I apologize in case I had to open another bug


Problem with Grub2 on my pc without"BLSCFG” configuration.

My system: 
Hard disk and mount points (all in ext4; is in this configuration from Fc19 or early)

sda   (HD)
    • sda1    “/home”    +    systemrescue “
      
      ls -al /home:
      
      drwxr-xr-x.   4 root    root         4096 19 nov 17.40 .
    • dr-xr-xr-x.  18 root    root         4096 20 ott 01.36 ..
    • drwx------. 125 alberto alberto     40960 24 nov 08.32 alberto
    • drwx------.   2 root    root        16384  7 lug  2012 lost+found
    • -rw-------.   1 root    root    720371712 19 nov 17.40 systemrescue-7.00-amd64.iso                           

sdb    (SSD)  (3 partitions)

    • sdb1    “ /  “  Fedora 31
    • sdb2    “ /  “  Fedora 33     (ex Fc29)
    • sdb3   partition mounted in “/mnt/AreaSSD”

sdc   (HD)   (2 partition)
    • sdc1   “ swap “  for Fc31 and Fc33   (same UUID in fstab; ~12 Gb for 16Gb ram)
    • sdc2   partition mounted in “/mnt/Archivio”

sdd   (HD)   (1 partition)
    • sdd1 partition mounted in “/mnt/Esterno”

*********************************
*********************************
Kernel at work:      kernel-5.9.8-200.fc33.x86_64

Kernel 5.8.8 installed by anaconda already removed after BLSCFG modified and grub2-mkconfig manually used.

New kernel installed after dnf update:         kernel-5.9.9-200.fc33.x86_64
Old kernel 5.9 not uninstalled.

After installation this are results of this command:      more /boot/grub2/grub.cfg | grep 5.9

………………….
menuentry 'Fedora (5.9.8-200.fc33.x86_64) 33 (Xfce)' …..
	linux	/boot/vmlinuz-5.9.8-200.fc33.x86_64 r ……..
	initrd	/boot/initramfs-5.9.8-200.fc33.x86_64.img
………………….

NO new kernel in grub.cfg
Also this morning, dnf update kernel to 5.9.10-200.
No automatic upgrade grub.cfg

Note: runnig  “grub2-mkconfig -o /boot/grub2/grub.cfg”  don’t resolve problem with BLSCFG=true.

*****************************************
Infact, also in FC31, I had to change in “/etc/default/grub”

GRUB_ENABLE_BLSCFG=true  in false.

Only after did this, I can execute manually:

grub2-mkconfig -o /boot/grub2/grub.cfg    with this answer:

Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.9.9-200.fc33.x86_64
Found initrd image: /boot/initramfs-5.9.9-200.fc33.x86_64.img
Found linux image: /boot/vmlinuz-5.9.8-200.fc33.x86_64
Found initrd image: /boot/initramfs-5.9.8-200.fc33.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-e86ca5e6d0c24205b33e7f5015ba4329
Found initrd image: /boot/initramfs-0-rescue-e86ca5e6d0c24205b33e7f5015ba4329.img
Found Fedora 31 (Thirty One) on /dev/sdb1
done

So:
1) without BLSCFG = “false” grub2-mkconfig (manually used) don’t work.
2) dnf update kernels, but every time I have to execute manually  “grub2-mkconfig”if I want use it from boot menu.

*******************************************************************
Another thing:

I wrote commands in “ /etc/grub.d/40_custom “ to use systemrescue.

menuentry "SystemRescue 7.00 (isoloop)" {
    load_video
    insmod gzio
    insmod part_gpt
    insmod part_msdos
    insmod ext2
    search --no-floppy --label home --set root='(hd1,1)'
    loopback loop (hd1,1)/systemrescue-7.00-amd64.iso
    echo   'Loading kernel ...'
    linux (loop)/sysresccd/boot/x86_64/vmlinuz img_label=home img_loop=/systemrescue-7.00-amd64.iso archisobasedir=sysresccd copytoram setkmap=it
    echo   'Loading initramfs ...'
    initrd (loop)/sysresccd/boot/x86_64/sysresccd.img
}

When I switch on my pc this menuentry appear in the menu (and I can use it), but, as you can see up it doesn’t appear on screen when grub2-mkconfig run.
I hope in future grub-mkconfig will do its work also it shall not say me.

Hy

Alberto Chiodi

Comment 3 Welterlen Benoit 2021-08-16 08:27:59 UTC
Hello,

Another situation where anaconda does not enable BLS support on Xen (AWS), but grub2-mkconfig is not run on kernel install:

---
   anaconda/grub2.py at f0df778cc43e2494fdd0fad131aa8643590510ac · rhinstaller/anaconda · GitHub
    https://github.com/rhinstaller/anaconda/blob/f0df778cc43e2494fdd0fad131aa8643590510ac/pyanaconda/modules/storage/bootloader/grub2.py#L252


        if self.use_bls and os.path.exists(conf.target.system_root + "/usr/sbin/new-kernel-pkg"):
            log.warning("BLS support disabled due new-kernel-pkg being present")
            self.use_bls = False

        hv_type_path = "/sys/hypervisor/type"
        if self.use_bls and os.access(hv_type_path, os.F_OK):
            with open(hv_type_path, "r") as fd:
                if fd.readline().strip() == "xen":
                    log.warning("BLS support disabled because is a Xen machine")
                    self.use_bls = False

        if self.use_bls:
            defaults.write("GRUB_ENABLE_BLSCFG=true\n")
        defaults.close()

~~~~~~~~~~~~~~~~
commit 6e268894c2484258ff98e399edef953e4bf4cfcc
Author: Javier Martinez Canillas <javierm>
Date:   Thu Oct 24 18:24:19 2019 +0200
 
    Don't enable BLS for Xen machines
   
    PV and PVH Xen DomU guests boot with pygrub that doesn't have BLS support.
    Also Xen Dom0 use the menuentries from 20_linux_xen and not the ones from
    10_linux. So BLS support needs to be disabled for both Xen Dom0 and DomU
    and use a traditional grub.cfg file generated by the grub2-mkconfig tool.
   
    Related: rhbz#1703700
~~~~~~~~~~~~~~~~

- BLS is supported on AWS

And in fedora, this is fixed by: https://bugzilla.redhat.com/show_bug.cgi?id=1703700

---
if [[ $HV_TYPE = "xen" && $XEN_DOM0 != "true" ]]; then
    RUN_MKCONFIG=true
    if grep -q '^GRUB_ENABLE_BLSCFG="*true"*\s*$' /etc/default/grub; then
        sed -i 's/^GRUB_ENABLE_BLSCFG=.*/GRUB_ENABLE_BLSCFG=false/' /etc/default/grub
    fi
fi
---

Thank you

Benoit Welterlen

Comment 18 errata-xmlrpc 2022-05-10 15:31:42 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Low: grub2 security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:2110


Note You need to log in before you can comment on or make changes to this bug.