RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2007297 - New installed kernel does not pick up current boot options in rhel9 kvm guest image
Summary: New installed kernel does not pick up current boot options in rhel9 kvm guest...
Keywords:
Status: CLOSED DUPLICATE of bug 1969362
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: grubby
Version: 9.0
Hardware: All
OS: Linux
urgent
urgent
Target Milestone: rc
: ---
Assignee: Bootloader engineering team
QA Contact: Release Test Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-09-23 14:13 UTC by Frank Liang
Modified: 2022-03-18 16:54 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-03-18 16:54:40 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-98199 0 None None None 2021-09-26 08:53:16 UTC

Description Frank Liang 2021-09-23 14:13:31 UTC
Description of problem:
Do upgrade in a RHEL-9 kvm guest image and the new kernel did not pick up current boot options.
Below is an example:
[root@ip-10-116-2-147 ec2-user]# cat /boot/grub2/grubenv
# GRUB Environment Block
kernelopts=root=UUID=a5530dec-3478-4c52-b301-709722dc3fac console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto rd.blacklist=nouveau nvme_core.io_timeout=4294967295
saved_entry=ec2a90c23a8028d854a96dc6025c1b49-5.14.0-1.2.1.el9.x86_64
boot_success=1
[root@ip-10-116-2-147 ec2-user]# cat /boot/loader/entries/ec2a90c23a8028d854a96dc6025c1b49-5.14.0-1.2.1.el9.x86_64.conf <- this is new installed kernel
title Red Hat Enterprise Linux (5.14.0-1.2.1.el9.x86_64) 9.0 (Plow)
version 5.14.0-1.2.1.el9.x86_64
linux /boot/vmlinuz-5.14.0-1.2.1.el9.x86_64
initrd /boot/initramfs-5.14.0-1.2.1.el9.x86_64.img
options root=UUID=a5530dec-3478-4c52-b301-709722dc3fac console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto
grub_users $grub_users
grub_arg --unrestricted
grub_class kernel

[root@ip-10-116-2-147 ec2-user]# cat /boot/loader/entries/ffffffffffffffffffffffffffffffff-5.14.0-0.rc7.54.el9.x86_64.conf <- this is old entry
title Red Hat Enterprise Linux (5.14.0-0.rc7.54.el9.x86_64) 9.0 (Plow)
version 5.14.0-0.rc7.54.el9.x86_64
linux /boot/vmlinuz-5.14.0-0.rc7.54.el9.x86_64
initrd /boot/initramfs-5.14.0-0.rc7.54.el9.x86_64.img
options root=UUID=a5530dec-3478-4c52-b301-709722dc3fac console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M rd.blacklist=nouveau nvme_core.io_timeout=4294967295
grub_users $grub_users
grub_arg --unrestricted
grub_class kernel

There is no such problem in the RHEL-8 ec2 image. The options is not hard coded in the entry file. And it is working in rhel9 too after changed 'options' to 'options $kernelopts $tuned_params  crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M'.
eg.
[root@dev209 test]# guestfish -a rhel-guest-image-8.5-1075.x86_64.qcow2 -i sh 'cat /boot/loader/entries/ffffffffffffffffffffffffffffffff-4.18.0-343.el8.x86_64.conf'
title Red Hat Enterprise Linux (4.18.0-343.el8.x86_64) 8.5 (Ootpa)
version 4.18.0-343.el8.x86_64
linux /boot/vmlinuz-4.18.0-343.el8.x86_64
initrd /boot/initramfs-4.18.0-343.el8.x86_64.img $tuned_initrd
options $kernelopts $tuned_params
id rhel-20210916231139-4.18.0-343.el8.x86_64
grub_users $grub_users
grub_arg --unrestricted
grub_class kernel

RHEL Version:
RHEL-9.0(5.14.0-1.2.1.el9.x86_64)

How reproducible:
100%

Steps to Reproduce:
1. boot a rhel9 kvm guest image and append new boot parameters to it.
2. after reboot, install new kernel and check if new added parameters are still there.

Actual results:
New installed kernel does not pick up current boot options
Expected results:
New installed kernel has the same boot options

Additional info:
- N/A

Comment 2 Christian Kellner 2021-09-23 14:51:16 UTC
The way that the kernel command line is integrated with the Boot Loader Specification changed in RHEL 9. As you noted, previously "$kernelopts" was included, which was set in the grubenv file. Now, to get static BLS config files, we include the kernel command line options when the BLS snippets are generated via "20-grub.install" and the options are taken from /etc/kernel/cmdline. In order to modify the kernel parameters permanently one has to edit that file.

Frank, what tooling did you use to change the kernel command line parameters? Maybe that tooling needs an update.

Comment 3 Frank Liang 2021-09-26 08:50:33 UTC
Thanks, Christian

I used grubby tool to update kernel boot parameters.
Here are results after appended 'kmemleak=on' as test parameter, grubby did not update "/etc/kernel/cmdline", so the new installed kernel does not carry over my test parameter.
I am moving this bug to grubby for more discussion.

The status after boot up rhel9 guest image.
[root@localhost ~]# grubby --update-kernel=ALL --args='kmemleak=on'
[root@localhost ~]# reboot
[root@localhost ~]# cat /etc/kernel/cmdline
root=UUID=95328833-60be-4de1-af21-8ac2d7dc6a37 console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto
[root@localhost ~]# cat /proc/cmdline 
BOOT_IMAGE=(hd0,gpt3)/boot/vmlinuz-5.14.0-1.2.1.el9.x86_64 root=UUID=95328833-60be-4de1-af21-8ac2d7dc6a37 console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M kmemleak=on

After installed new kernel and reboot, 'kmemleak=one' is not carried over.
[root@localhost ~]# cat /proc/cmdline 
BOOT_IMAGE=(hd0,gpt3)/boot/vmlinuz-5.14.0-4.el9.x86_64 root=UUID=95328833-60be-4de1-af21-8ac2d7dc6a37 console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crash
kernel=auto

Comment 6 Jared Dominguez 2021-11-03 13:48:20 UTC
If I'm understanding correctly, and Christian Kellner mentions this too in c#2, this is because RHEL 9 doesn't use $kernelopts anymore. Here is a response from Javier Martinez Canillas to a similar question recently:
"""
> Just so I'm clear, you're saying that kernelopts is not set in RHEL 9?
>

That is correct, it's not used anymore in neither Fedora nor RHEL 9. It is
still in RHEL 8 since we couldn't drop it in the middle of a RHEL life cycle.

Using an environment variable in GRUB's env block turned out to cause more
harm than good, so it was decided to be dropped and instead store the cmdline
in the BLS snippets themselves. You can get a better explanation from:

https://src.fedoraproject.org/rpms/grub2/c/4a742183a39f

Doing that way also aligns better with what the OSTree-based Fedora/RHEL OS
variants do and also what's done for other arches (i.e: the zipl bootloader
used in s390x doesn't support vars and the cmdline is stored in BLS files).
"""

Comment 7 Frank Liang 2021-12-16 03:03:57 UTC
Hi Tomas,

Could you help check if '/etc/kernel/cmdline' is generated by imagebuilder?
There is no such file if system is installed from iso directly and new installed kernel always picks current boot options from /proc/cmdline as expected.

In this case, if '/etc/kernel/cmdline' exists, the new installed kernel picks it with higher priority and ignore all I appended in current running kernel.
I guess that most users want to take '/proc/cmdline' to new installed kernel instead of restoring it to default in "/etc/kernel/cmdline".

# cat /etc/kernel/cmdline
root=UUID=8d347296-a296-47f6-b707-e1c9aac9b833 console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto

Below is instruction from systemd.
<listitem>
    <para>Read by <filename>90-loaderentry.install</filename>. The content of the file
    <filename>/etc/kernel/cmdline</filename> specifies the kernel command line to use.  If that file does not
    exist, <filename>/proc/cmdline</filename> is used.</para>
</listitem>

# cat /proc/cmdline 
BOOT_IMAGE=(hd0,gpt2)/boot/vmlinuz-5.14.0-31.el9.x86_64 root=UUID=8d347296-a296-47f6-b707-e1c9aac9b833 console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M

Comment 8 Christian Kellner 2021-12-16 08:55:42 UTC
Hi Frank,

in the KVM guest image (and indeed all guest/cloud images that were build via Image Builder) we always had a configuration file for the kernel command line: For RHEL8 (and Fedora < 33) it was the grubenv file in /boot/grub2/grubenv which contained the "kernelopts" variable. The Boot Loader Specification snippets that were generated during kernel install by 20-grub.install (provided by grub2) always had "options \$kernelopts", i.e. all the kernel options came only from the grubenv file.
This changed in Fedora 33 (see [1]). Now the Boot Loader Specification snippets always contain the full command line (grubenv is not used anymore). Instead, as you pointed out, /usr/kernel/cmdline, then /etc/kernel/cmdline is used for the system-wide persistent configuration and if neither exist we fall back to /proc/cmdline. Image Builder followed that change and now instead of writing the persistent kernel command line to /boot/grub2/grubenv it is writing it to /etc/kernel/cmdline.

Not writing the persistent kernel command line to a configuration file would be a change in behaviour, that could easily lead to unexpected behaviour. One example: you boot the system but change the kernel command line via the grub2 menu, so that for the current kernel it is changed (but only transiently, i.e. rebooting the system would give you the old kernel command line). If you install a new kernel while you have that transient change booted and we have no configuration file, that transient command line would now (via /proc/cmdline) end up in the newly installed kernel, but _not_ in the old kernel.

This is all a long version of saying, it is intended to have a persistent kernel configuration which used to be /boot/grub2/grubenv and now is /usr/kernel/cmdline.


[1] https://src.fedoraproject.org/rpms/grub2/c/4a742183a39f344a7685bccdc76d5e64dea3766a?branch=f33

Comment 9 Frank Liang 2021-12-16 13:18:26 UTC
(In reply to Christian Kellner from comment #8)
> Hi Frank,
> 
> in the KVM guest image (and indeed all guest/cloud images that were build
> via Image Builder) we always had a configuration file for the kernel command
> line: For RHEL8 (and Fedora < 33) it was the grubenv file in
> /boot/grub2/grubenv which contained the "kernelopts" variable. The Boot
> Loader Specification snippets that were generated during kernel install by
> 20-grub.install (provided by grub2) always had "options \$kernelopts", i.e.
> all the kernel options came only from the grubenv file.
> This changed in Fedora 33 (see [1]). Now the Boot Loader Specification
> snippets always contain the full command line (grubenv is not used anymore).
> Instead, as you pointed out, /usr/kernel/cmdline, then /etc/kernel/cmdline
> is used for the system-wide persistent configuration and if neither exist we
> fall back to /proc/cmdline. Image Builder followed that change and now
> instead of writing the persistent kernel command line to /boot/grub2/grubenv
> it is writing it to /etc/kernel/cmdline.
> 
> Not writing the persistent kernel command line to a configuration file would
> be a change in behaviour, that could easily lead to unexpected behaviour.
> One example: you boot the system but change the kernel command line via the
> grub2 menu, so that for the current kernel it is changed (but only
> transiently, i.e. rebooting the system would give you the old kernel command
> line). If you install a new kernel while you have that transient change
> booted and we have no configuration file, that transient command line would
> now (via /proc/cmdline) end up in the newly installed kernel, but _not_ in
> the old kernel.
> 
> This is all a long version of saying, it is intended to have a persistent
> kernel configuration which used to be /boot/grub2/grubenv and now is
> /usr/kernel/cmdline.
> 
> 
> [1]
> https://src.fedoraproject.org/rpms/grub2/c/
> 4a742183a39f344a7685bccdc76d5e64dea3766a?branch=f33

Thanks, Christian

So I guess grubby tool should handle such case accordingly when update, add, remove boot parameters, make changes in '/etc/kernel/cmdline' if it exists.

Comment 12 Robbie Harwood 2022-03-18 16:54:40 UTC

*** This bug has been marked as a duplicate of bug 1969362 ***


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