Bug 1900829

Summary: Arguments from running system are used if --args is not specified
Product: Red Hat Enterprise Linux 8 Reporter: Jan Stodola <jstodola>
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: 8.3CC: jsvarova, kperrier, lmanasko, mlewando, nfrayer, pjanda, rdulhani
Target Milestone: rcKeywords: Triaged
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: grubby-8.40-48.el8 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:
: 2127453 (view as bug list) Environment:
Last Closed: 2023-11-14 15:50:32 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:    
Bug Blocks: 1879091, 1903942, 2127453    

Description Jan Stodola 2020-11-23 19:42:01 UTC
Description of problem:
When adding a new kernel and the --args option is not specified, the kernel arguments from the running kernel are used (except of the root= argument):

[root@localhost ~]# cd /boot/
[root@localhost boot]# touch my_kernel my_initrd
[root@localhost boot]# grubby --add-kernel=/boot/my_kernel --initrd=/boot/my_initrd --title=no_args
[root@localhost 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/2d33c9bc03a345b4990f71804c74e899-my_kernel.0~custom.conf

[root@localhost boot]# grubby --info=/boot/my_kernel
index=2
kernel="/boot/my_kernel"
args="bla"
initrd="/boot/my_initrd"
title="some_args"
id="2d33c9bc03a345b4990f71804c74e899-my_kernel.0~custom"
index=3
kernel="/boot/my_kernel"
args="ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet"
root="/dev/mapper/rhel-root"
initrd="/boot/my_initrd"
title="no_args"
id="2d33c9bc03a345b4990f71804c74e899-my_kernel"

[root@localhost boot]# cat /proc/cmdline 
BOOT_IMAGE=(hd0,msdos1)/vmlinuz-4.18.0-246.el8.dt4.x86_64 root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet

[root@localhost boot]# rpm -q grubby
grubby-8.40-41.el8.x86_64
[root@localhost boot]#


Compare with RHEL-7:

[root@dhcp76 ~]# cd /boot/
[root@dhcp76 boot]# touch my_kernel my_initrd
[root@dhcp76 boot]# grubby --add-kernel=/boot/my_kernel --initrd=/boot/my_initrd --title=no_args
[root@dhcp76 boot]# grubby --add-kernel=/boot/my_kernel --initrd=/boot/my_initrd --args=bla --title=some_args
[root@dhcp76 boot]# grubby --info=/boot/my_kernel
index=0
kernel=/boot/my_kernel
args="bla"
initrd=/boot/my_initrd
title=some_args
index=1
kernel=/boot/my_kernel
initrd=/boot/my_initrd
title=no_args
[root@dhcp76 boot]# rpm -q grubby
grubby-8.28-26.el7.x86_64
[root@dhcp76 boot]#


Version-Release number of selected component (if applicable):
grubby-8.40-41.el8

How reproducible:
always

Steps to Reproduce:
1. see above

Actual results:
args="ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet"

Expected results:
empty/no args, like in the RHEL-7 case.

Comment 1 Jan Stodola 2020-11-23 19:47:17 UTC
And it also doesn't help using an empty string for --args:

[root@localhost boot]# grubby --add-kernel=/boot/my_kernel --initrd=/boot/my_initrd --args="" --title=empty_args
An entry for kernel my_kernel already exists, adding /boot/loader/entries/2d33c9bc03a345b4990f71804c74e899-my_kernel.4~custom.conf
[root@localhost boot]# grubby --info=/boot/my_kernel
index=2
kernel="/boot/my_kernel"
args="ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet"
root="/dev/mapper/rhel-root"
initrd="/boot/my_initrd"
title="empty_args"
id="2d33c9bc03a345b4990f71804c74e899-my_kernel.4~custom"
...

Comment 7 Petr Janda 2022-09-09 13:53:41 UTC
From man page of grubby-8.40-42.el8

--args=kernel-args
        When  a  new  kernel  is  added, this specifies the command line
        arguments which should be passed to the kernel by default  (note
        they  are  merged  with  the  arguments  of the default entry if
        --copy-default is used).  When  --update-kernel  is  used,  this
        specifies  new  arguments to add to the argument list. Multiple,
        space separated arguments may be used. If  an  argument  already
        exists  the  new value replaces the old values. The root= kernel
        argument gets special handling if  the  configuration  file  has
        special handling for specifying the root filesystem.

which leads me in opinion that reporter is right and args shouldn't be copied by default (otherwise the option --copy-default doesn't make any sense)

I would also note that when installing a new kernel (yum update| yum install some_new_kernel_package) users expects to have arguments copied to a new kernel.

Comment 22 Marta Lewandowska 2023-06-14 08:44:23 UTC
Reproduced with grubby-8.40-47.el8

[root@kvm-06-guest18 ~]# cd /boot/
[root@kvm-06-guest18 boot]# cp vmlinuz-4.18.0-494.el8.x86_64 kernel
[root@kvm-06-guest18 boot]# cp initramfs-4.18.0-494.el8.x86_64.img initrd
[root@kvm-06-guest18 boot]# grubby --add-kernel=/boot/kernel --initrd=/boot/initrd --title=no_args
[root@kvm-06-guest18 boot]# grubby --add-kernel=/boot/kernel --initrd=/boot/initrd --args bla --title=some_args
An entry for kernel kernel already exists, adding /boot/loader/entries/1a405ee0007847188d2ec98b45d16ef5-kernel.0~custom.conf

[root@kvm-06-guest18 boot]# grubby --info /boot/kernel 
index=2
kernel="/boot/kernel"
args="bla"
initrd="/boot/initrd"
title="some_args"
id="1a405ee0007847188d2ec98b45d16ef5-kernel.0~custom"
index=3
kernel="/boot/kernel"
args="ro crashkernel=auto resume=/dev/mapper/rhel_kvm--06--guest18-swap rd.lvm.lv=rhel_kvm-06-guest18/root rd.lvm.lv=rhel_kvm-06-guest18/swap console=ttyS0,115200"
root="/dev/mapper/rhel_kvm--06--guest18-root"
initrd="/boot/initrd"
title="no_args"
id="1a405ee0007847188d2ec98b45d16ef5-kernel"


Verified with grubby-8.40-48.el8

[root@kvm-06-guest18 yum.repos.d]# grubby --add-kernel=/boot/kernel --initrd=/boot/initrd --title=no_args

[root@kvm-06-guest18 yum.repos.d]# grubby --add-kernel=/boot/kernel --initrd=/boot/initrd --args bla --title=some_args
bla
An entry for kernel kernel already exists, adding /boot/loader/entries/1a405ee0007847188d2ec98b45d16ef5-kernel.0~custom.conf
[root@kvm-06-guest18 yum.repos.d]# grubby --info /boot/kernel 
index=2
kernel="/boot/kernel"
args="bla"
initrd="/boot/initrd"
title="some_args"
id="1a405ee0007847188d2ec98b45d16ef5-kernel.0~custom"
index=3
kernel="/boot/kernel"
args=""
initrd="/boot/initrd"
title="no_args"
id="1a405ee0007847188d2ec98b45d16ef5-kernel"

What do you think, Honzo?

Comment 25 Marta Lewandowska 2023-06-14 09:10:15 UTC
on s390x with grubby-8.40-47.el8:
[root@rtt4 ~]# grubby --info /boot/my_kernel 
index=2
kernel="/boot/my_kernel"
args="bla"
initrd="/boot/my_initrd"
title="some_args"
id="1c534e15c4d0431a8442025814218543-my_kernel.0~custom"
index=3
kernel="/boot/my_kernel"
args="$kernelopts"
initrd="/boot/my_initrd"
title="no_args"
id="1c534e15c4d0431a8442025814218543-my_kernel"

on s390x with new grubby-8.40-48.el8:
[root@rtt4 ~]# grubby --info /boot/my_kernel 
index=2
kernel="/boot/my_kernel"
args="bla"
initrd="/boot/my_initrd"
title="some_args"
id="1c534e15c4d0431a8442025814218543-my_kernel.0~custom"
index=3
kernel="/boot/my_kernel"
args=""
initrd="/boot/my_initrd"
title="no_args"
id="1c534e15c4d0431a8442025814218543-my_kernel"

Comment 26 Jan Stodola 2023-06-14 09:41:13 UTC
It looks great, thanks Marta!

Comment 27 Marta Lewandowska 2023-06-14 09:44:09 UTC
Awesome. thank you.
Setting Verified: Tested

Comment 28 Marta Lewandowska 2023-06-14 09:46:17 UTC
@jsvarova FYI, this is fixed now in RHEL-8 as well (it got fixed in RHEL-9 last release, so you can re-use the same text)

Comment 34 errata-xmlrpc 2023-11-14 15:50:32 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:7141