Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 2127453

Summary: Default arguments are used if --args is not specified
Product: Red Hat Enterprise Linux 9 Reporter: Marta Lewandowska <mlewando>
Component: grubbyAssignee: Bootloader engineering team <bootloader-eng-team>
Status: CLOSED ERRATA QA Contact: Release Test Team <release-test-team-automation>
Severity: medium Docs Contact: Jana Heves <jsvarova>
Priority: high    
Version: 9.1CC: bootloader-eng-team, gfialova, jstodola, jsvarova, kperrier, mlewando, pjanda, rdulhani, release-test-team-automation
Target Milestone: rcKeywords: Triaged
Target Release: 9.2Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: grubby-8.40-63.el9 Doc Type: Bug Fix
Doc Text:
.`grubby` now passes arguments to a new kernel correctly When you add a new kernel using the `grubby` tool and do not specify any arguments, or leave the arguments blank, `grubby` will not pass any arguments to the new kernel and `root` will not be set. Using the `--args` and `--copy-default` options ensures new arguments are appended to the default arguments.
Story Points: ---
Clone Of: 1900829 Environment:
Last Closed: 2023-05-09 08:26:25 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:
Bug Depends On: 1900829    
Bug Blocks: 1879091, 1903942    

Comment 1 Marta Lewandowska 2022-09-20 06:27:23 UTC
diff --git a/grubby-bls b/grubby-bls
index fd76f63..f09156b 100755
--- a/grubby-bls
+++ b/grubby-bls
@@ -827,13 +827,14 @@ fi
 remove_var_prefix "$(get_prefix)"
 
 if [[ -n $kernel ]]; then
-    opts="${bls_options[$default_index]}"
-    if [[ $copy_default != "true" ]]; then
-        opts=$(echo $opts | sed -e 's/ .*//')
+    if [[ $copy_default = "true" ]]; then
+       opts="${bls_options[$default_index]}"
+       if [[ -n $args ]]; then
+           opts="${opts} ${args}"
+       fi
+    else
+       opts="${args}"
     fi
-    if [[ -n $args ]]; then
-        opts="${opts} ${args}"
-    fi    
 
     add_bls_fragment "${kernel}" "${title}" "${opts}" "${initrd}" \
                      "${extra_initrd}"

Comment 2 Robbie Harwood 2022-10-04 17:20:03 UTC
Thanks, applied fix to Fedora.

Comment 10 Marta Lewandowska 2023-02-16 14:26:13 UTC
Reproduced on RHEL-9.2 with grubby 8.40-61:
# rpm -qa grubby\*
grubby-8.40-61.el9.x86_64
[root@kvm-08-guest31 ~]# cd /boot/
[root@kvm-08-guest31 boot]# touch my_kernel my_initrd
[root@kvm-08-guest31 boot]# grubby --add-kernel=/boot/my_kernel --initrd=/boot/my_initrd --title=no_args
[root@kvm-08-guest31 boot]# grubby --add-kernel=/boot/my_kernel --initrd=/boot/my_initrd --args=bla --title=some_args
An entry for kernel my_kernel already exists, adding /boot/loader/entries/5c9135a4657146f3bcd4a2844700f9bd-my_kernel.0~custom.conf

[root@kvm-08-guest31 boot]# grubby --info=/boot/my_kernel
index=2
kernel="/boot/my_kernel"
args="bla"
initrd="/boot/my_initrd"
title="some_args"
id="5c9135a4657146f3bcd4a2844700f9bd-my_kernel.0~custom"

index=3
kernel="/boot/my_kernel"
args="$kernelopts"
initrd="/boot/my_initrd"
title="no_args"
id="5c9135a4657146f3bcd4a2844700f9bd-my_kernel"

Verified on RHEL-9.2 with grubby 8.40-62:
# rpm -qa grubby\*
grubby-8.40-62.el9.aarch64
[root@hpe-apollo-cn99xx-15-vm-20 ~]# cd /boot
[root@hpe-apollo-cn99xx-15-vm-20 boot]# touch my_kernel my_initrd
[root@hpe-apollo-cn99xx-15-vm-20 boot]# grubby --add-kernel=/boot/my_kernel --initrd=/boot/my_initrd --title=no_args
[root@hpe-apollo-cn99xx-15-vm-20 boot]# grubby --add-kernel=/boot/my_kernel --initrd=/boot/my_initrd --args=bla --title=some_args
An entry for kernel my_kernel already exists, adding /boot/loader/entries/c08f08492d714fc087dcb5accc2746fc-my_kernel.0~custom.conf

[root@hpe-apollo-cn99xx-15-vm-20 boot]# grubby --info=/boot/my_kernel
index=2
kernel="/boot/my_kernel"
args="bla"
root="/dev/mapper/rhel_hpe--apollo--cn99xx--15--vm--20-root"
initrd="/boot/my_initrd"
title="some_args"
id="c08f08492d714fc087dcb5accc2746fc-my_kernel.0~custom"

index=3
kernel="/boot/my_kernel"
args=""
root="/dev/mapper/rhel_hpe--apollo--cn99xx--15--vm--20-root"
initrd="/boot/my_initrd"
title="no_args"
id="c08f08492d714fc087dcb5accc2746fc-my_kernel"

root is set, default arguments are not copied.

Comment 15 Jan Stodola 2023-02-20 12:29:31 UTC
grubby-8.40-62.el9 adds an unexpected root=... boot argument when the user specifies --args=... See:

[root@localhost boot]# grubby --add-kernel=/boot/vmlinuz --initrd=/boot/initrd.img --args="my_arg" --title="Test"
[root@localhost boot]# cat /boot/loader/entries/dc227bca83644c7aad89fa7e31bb3e4e-vmlinuz.conf 
title Test
version vmlinuz
linux /vmlinuz
initrd /initrd.img
options root=/dev/mapper/rhel-root my_arg
id rhel-0-vmlinuz
grub_users $grub_users
grub_arg --unrestricted
grub_class kernel
[root@localhost boot]#

The expected behavior is that only "my_arg" would be present on the kernel command line, root=/dev/mapper/rhel-root should not be there.

I'm moving this bug back to ASSIGNED. This is a change of behavior and has an impact on our automated testing.

Comment 17 Marta Lewandowska 2023-02-22 09:19:59 UTC
I thought the root= was desired! But since it is not, here it is again with grubby-8.40-63.el9:

[root@ibm-p9z-23-lp3 boot]# grubby --add-kernel my_kernel --initrd my_initrd --title no_args

[root@ibm-p9z-23-lp3 boot]# grubby --add-kernel my_kernel --initrd my_initrd --args args --title some_args
args
An entry for kernel my_kernel already exists, adding /boot/loader/entries/a7c94d39d09c4db1a076bdfc5ca994e7-my_kernel.0~custom.conf

[root@ibm-p9z-23-lp3 boot]# grubby --info my_kernel
index=2
kernel="/boot/my_kernel"
args="args"
initrd="/boot/my_initrd"
title="some_args"
id="a7c94d39d09c4db1a076bdfc5ca994e7-my_kernel.0~custom"

index=3
kernel="/boot/my_kernel"
args=""
initrd="/boot/my_initrd"
title="no_args"
id="a7c94d39d09c4db1a076bdfc5ca994e7-my_kernel"

Comment 18 Jan Stodola 2023-02-22 09:38:00 UTC
The results from comment 17 look good, thank you Marta.

Comment 19 Marta Lewandowska 2023-02-22 09:40:27 UTC
You're welcome, Honzo. :)
Setting back to Verified: Tested based on c#17 & 18

Comment 29 errata-xmlrpc 2023-05-09 08:26:25 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 (grubby 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:2584