Bug 1213822 - invalid grub.cfg created with INITRD_IN_POSTTRANS=1
Summary: invalid grub.cfg created with INITRD_IN_POSTTRANS=1
Status: RESOLVED FIXED
Alias: None
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: Current
Hardware: Other Other
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: Martin Wilck
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-31 14:44 UTC by Martin Wilck
Modified: 2023-10-05 16:29 UTC (History)
1 user (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Wilck 2023-07-31 14:44:43 UTC
Invalid boot entry is generated with latest TW update and INITRD_IN_POSTTRANS=1 set:

        echo    'Loading Linux 6.4.6-1-default ...'
        linux   /boot/vmlinuz-6.4.6-1-default root=/dev/sda7
/dev/sda5  ${extra_cmdline} sysrq_always_enabled panic=100 ignore_loglevel unknown_nmi_panic resume=/dev/sda6 crashkernel=128M@256M showopts

The root device in question is a btrfs device with two members, where grub2-probe prints this:

# grub2-probe --target=device /
/dev/sda7
/dev/sda5

The issue happened because the update transaction comprised both a grub2 update and a kernel-default update. With INITRD_IN_POSTTRANS=1, if the posttrans script of grub2-x86_64-efi is executed before the posttrans script of kernel-default, the initrd will not exist at the time grub2-mkconfig is run, and the following code from /etc/grub.d/10_linux will be executed:

  if test -z "${initramfs}" && test -z "${initrd_real}" ; then
    # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs.  Since there's
    # no initrd or builtin initramfs, it can't work here.
    if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \
        || [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then

        linux_root_device_thisversion=${GRUB_DEVICE}
    else
        linux_root_device_thisversion=PARTUUID=${GRUB_DEVICE_PARTUUID}
    fi
  fi

This will cause the wrong grub.cfg entry shown above. The script assumes that if no initrd exists at the time it is running, there will be none later, either.

This assumption is arguably wrong under SUSE and openSUSE, where we always have an initrd — it would be smarter to assume that if no initrd exists, it will be created later. Also, it's very questionable to create a syntactically wrong boot entry rather than a (possibly) unparseable UUID= entry.

The initramfs is created later in the installation process, when the posttrans script of kernel-default is run; but that won't cause the grub.cfg file to be regenerated.

We need to make sure that grub2-mkconfig is run after initrd creation.
This needs to be fixed in suse-module-tools.
Comment 2 OBSbugzilla Bot 2023-08-15 17:05:03 UTC
This is an autogenerated message for OBS integration:
This bug (1213822) was mentioned in
https://build.opensuse.org/request/show/1104074 Factory / suse-module-tools
Comment 5 Martin Wilck 2023-09-18 14:48:00 UTC
Fixed in TW and SLE15-SP6 (see above).

This fixes a bug introduced with the fix for bsc#1212957 ("check for regenerate-initrd-posttrans in %posttrans") which is not currently included in SLE15-SP5.
The pending MU for SLE15-SP5 includes the fix for 1213822.

Closing.
Comment 8 Maintenance Automation 2023-10-05 16:29:40 UTC
SUSE-RU-2023:3985-1: An update that has four fixes can now be installed.

Category: recommended (important)
Bug References: 1201066, 1212957, 1213428, 1213822
Sources used:
openSUSE Leap 15.5 (src): suse-module-tools-15.5.2-150500.3.3.1
Basesystem Module 15-SP5 (src): suse-module-tools-15.5.2-150500.3.3.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.