Bug 2149232

Summary: dracut-initramfs-restore always fails
Product: Red Hat Enterprise Linux 9 Reporter: Renaud Métrich <rmetrich>
Component: dracutAssignee: Pavel Valena <pvalena>
Status: CLOSED ERRATA QA Contact: Frantisek Sumsal <fsumsal>
Severity: high Docs Contact:
Priority: high    
Version: 9.1CC: dtardon, fsumsal, myamazak, pvalena
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: dracut-057-20.git20221213.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-09 08:24:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Renaud Métrich 2022-11-29 09:56:48 UTC
Description of problem:

With new release of dracut, dracut-initramfs-restore always fails to unpack the initramfs because it searches for a non-existing file on RHEL.
It's selecting line 35 because we have /boot/loader/entries directory, but it should select line 42 instead.

New release:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
 28 mount -o ro /boot &> /dev/null || true
 29 
 30 if [[ -d /efi/loader/entries ]] || [[ -L /efi/loader/entries ]] \
 31     || [[ -d /efi/$MACHINE_ID ]] || [[ -L /efi/$MACHINE_ID ]]; then
 32     IMG="/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
 33 elif [[ -d /boot/loader/entries ]] || [[ -L /boot/loader/entries ]] \
 34     || [[ -d /boot/$MACHINE_ID ]] || [[ -L /boot/$MACHINE_ID ]]; then
 35     IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
 36 elif [[ -d /boot/efi/loader/entries ]] || [[ -L /boot/efi/loader/entries ]] \
 37     || [[ -d /boot/efi/$MACHINE_ID ]] || [[ -L /boot/efi/$MACHINE_ID ]]; then
 38     IMG="/boot/efi/$MACHINE_ID/$KERNEL_VERSION/initrd"
 39 elif [[ -f /lib/modules/${KERNEL_VERSION}/initrd ]]; then
 40     IMG="/lib/modules/${KERNEL_VERSION}/initrd"
 41 elif [[ -f /boot/initramfs-${KERNEL_VERSION}.img ]]; then
 42     IMG="/boot/initramfs-${KERNEL_VERSION}.img"
 43 elif mountpoint -q /efi; then
 44     IMG="/efi/$MACHINE_ID/$KERNEL_VERSION/initrd"
 45 elif mountpoint -q /boot/efi; then
 46     IMG="/boot/efi/$MACHINE_ID/$KERNEL_VERSION/initrd"
 47 else
 48     echo "No initramfs image found to restore!"
 49     exit 1
 50 fi
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Previous release is correct because of the checks on line 25-26 which do not apply to RHEL9.

Previous release (055-45.git20220404.el9_0):
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
 22 mount -o ro /boot &> /dev/null || true
 23 
 24 if [[ -d /efi/loader/entries || -L /efi/loader/entries ]] \
 25     && [[ $MACHINE_ID ]] \
 26     && [[ -d /efi/${MACHINE_ID} || -L /efi/${MACHINE_ID} ]]; then
 27     IMG="/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
 28 elif [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \
 29     && [[ $MACHINE_ID ]] \
 30     && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]]; then
 31     IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
 32 elif [[ -f /boot/initramfs-${KERNEL_VERSION}.img ]]; then
 33     IMG="/boot/initramfs-${KERNEL_VERSION}.img"
 34 elif [[ -f /lib/modules/${KERNEL_VERSION}/initrd ]]; then
 35     IMG="/lib/modules/${KERNEL_VERSION}/initrd"
 36 else
 37     echo "No initramfs image found to restore!"
 38     exit 1
 39 fi
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------


Additionally, but unrelated, the kernel always complains when the mount of /boot happens:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
kernel: sda2: Can't mount, would change RO state
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

This is due to /boot already been mounted (usually), and line 28 (in newer dracut) to fail.
It would be nice to check if /boot is already a mount point to avoid this message, which may the admin believe there is something wrong with /dev/sda2 (e.g. it would be corrupted).


Version-Release number of selected component (if applicable):

dracut-057-13.git20220816.el9.x86_64

How reproducible:

Always

Steps to Reproduce:
1. Reboot with persistent journal enabled

Actual results:

Failure to unpack the initramfs

Expected results:

No issue

Comment 13 errata-xmlrpc 2023-05-09 08:24:17 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 (dracut 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/RHBA-2023:2547