Skip to content

Use grubby to update kernel command line arguments - #511

Open
mihaelabalutoiu wants to merge 1 commit into
cloudbase:masterfrom
mihaelabalutoiu:add-grubby-kernel-opts
Open

Use grubby to update kernel command line arguments#511
mihaelabalutoiu wants to merge 1 commit into
cloudbase:masterfrom
mihaelabalutoiu:add-grubby-kernel-opts

Conversation

@mihaelabalutoiu

Copy link
Copy Markdown
Member

Failing to update the kernel console options breaks text console functionality on affected platforms.

The issue is caused by BLS being enabled by default in /etc/default/grub. On RHEL 10, kernel arguments are managed through /boot/loader/entries, and grub2-mkconfig does not propagate the updated options there.

This PR implements the following:

  • Uses grubby --update-kernel=ALL to update kernel arguments on BLS-based systems.
  • Falls back to the existing grub2-mkconfig logic when grubby is not available.

Use "grubby --update-kernel=ALL" to update kernel arguments on
BLS-based systems such as RHEL 10, where grub2-mkconfig does not
propagate them to `/boot/loader/entries`.

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
"sed -i '/cloud-init=disabled/d' %s" % grub_conf_disabler
)
self._schedule_grub2_update()
self._update_kernel_cmdline_args(args_to_remove=["cloud-init=disabled"])

@Dany9966 Dany9966 Aug 31, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that both grub update and grubby are being called. It should be the one or the other, not both.

An ideal implementation would be to call for _update_kernel_cmdline_args indeed, but you only implemented it for redhat based. There should also be a debian implementation which does the former (reads /etc/default/grub, removes/adds/edits the cmdline, schedules grub2 update).

I propose the following:

  1. Use Grub2ConfigEditor whenever possible instead of sed-ing the file directly.
    This implies implementing a new method to remove cmdline entries, call it remove_from_option
    This method should pretty much emulate what grubby does on redhat, and that is if you pass a single option
    (--remove-args=cloud-init), then it will be removed even if it's a key_val, no matter what value cloud-init has
    in cmdline. If you pass a key_val, then only remove the key if the value matches
    (--remove-args=cloud-init=disabled only remove cloud-init from cmdline if it's disabled, but won't
    remove cloud-init=enabled).

  2. We should somehow abstractize this for redhat. On base, when calling for _update_kernel_cmdline_args,
    it should instantiate a Grub2ConfigEditor, append or remove from GRUB_CMDLINE_LINUX and
    GRUB_CMDLINE_LINUX_DEFAULT options (depending on what args_to_add or args_to_remove are being
    passed).
    If it's redhat, then simply use grubby to handle args_to_add/args_to_remove

  3. (only if grubby commands take too long, otherwise treat this as optional) I think the final grubby command should also be run once at the end, so add some schedule_grubby
    methods as well when adding args to remove/add. (similar to _schedule_grub2_update)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants