Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for installing static grub configs #543

Merged
merged 2 commits into from
Oct 19, 2023

Conversation

cgwalters
Copy link
Member

grub: Support multiple platform files

In practice, just one should be enough but let's expand
in case.


Add support for installing static grub configs

Currently these are duplicated in osbuild and coreos-assembler.
We will aim to deduplicate them here.

Ideally we'd add support for "day 2" updates of these; I started
on a patch for that but it's sadly messy.

This is an incremental improvement.


@cgwalters cgwalters marked this pull request as draft October 3, 2023 18:02
@cgwalters cgwalters force-pushed the install-grub-configs-simpler branch 3 times, most recently from 629918d to 8b88e3f Compare October 6, 2023 21:26
@cgwalters cgwalters marked this pull request as ready for review October 6, 2023 21:26
@cgwalters
Copy link
Member Author

OK this is now tested in concert with coreos/coreos-assembler#3631

src/grub2/grub-static.cfg Outdated Show resolved Hide resolved
if [ -n "${boot_counter}" -a "${boot_success}" = "0" ]; then
# if countdown has ended, choose to boot rollback deployment,
# i.e. default=1 on OSTree-based systems.
if [ "${boot_counter}" = "0" -o "${boot_counter}" = "-1" ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

why forcing 0 to be -1 when it can happen with decrement boot_counter automatically , I have seen similar things here , couldn't understand the logic behind this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have no idea either, I'm just copying it from the osbuild code.

But actually the more I think about this, the more it feels like the right move actually is to keep these grub drop-ins in ignition.rpm and greenboot.rpm respectively in say /usr/lib/bootupd/grub2-static or so. WDYT?

Copy link
Collaborator

@say-paul say-paul Oct 11, 2023

Choose a reason for hiding this comment

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

having it in rpm makes sense, though during the installation process I am not sure how to set that up in grub.cfg , which image builder writes it directly in the config

Copy link
Member Author

Choose a reason for hiding this comment

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

The higher level direction here is we will switch Image Builder (Edge) to basically run bootupctl backend install instead of owning the bootloader configs and grub installation on its own.

Copy link
Collaborator

@say-paul say-paul Oct 18, 2023

Choose a reason for hiding this comment

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

Seems fair.
May not be an appropriate question, still I am going to ask to clear my doubts: Though I dont see many user doing this , but package installed using using rpm installer will require additional bootupctl backend install to be run again to update the bootloader configs?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't directly support updating the configs yet.

(In practice of course, it will trivially work to just cp them manually)

@cgwalters cgwalters force-pushed the install-grub-configs-simpler branch from 8b88e3f to f9ce09c Compare October 12, 2023 13:59
cgwalters added a commit to cgwalters/ignition that referenced this pull request Oct 12, 2023
This pairs with coreos/bootupd#543
Basically we want bootupd to take care of installing this.  Add
the config here (where it more closely arguably belongs) so
that it can be optionally installed.

My proposal for at least the Fedora packaging of Ignition
is that we unconditionally depend on bootupd and install this,
because there's no one there using Ignition who doesn't want bootupd.
@cgwalters
Copy link
Member Author

xref coreos/ignition#1728

cgwalters added a commit to cgwalters/coreos-assembler that referenced this pull request Oct 12, 2023
cgwalters added a commit to cgwalters/coreos-assembler that referenced this pull request Oct 12, 2023
This ensures that we'll use `/boot/efi` first, which is what
is more commonly expected in our current ecosystem.
@cgwalters cgwalters force-pushed the install-grub-configs-simpler branch from f9ce09c to c37f0d3 Compare October 16, 2023 19:20
@cgwalters cgwalters requested a review from say-paul October 17, 2023 12:31
@travier
Copy link
Member

travier commented Oct 17, 2023

Not tested but LGTM.

I would recommend forcing a number-prefixed format for the XY-foo.cfg drop-ins so that we have a strong ordering guarantee for the final config.

Makefile Outdated Show resolved Hide resolved
@cgwalters cgwalters force-pushed the install-grub-configs-simpler branch 2 times, most recently from fcf0dab to 45fe1ae Compare October 17, 2023 13:10
@cgwalters
Copy link
Member Author

I would recommend forcing a number-prefixed format for the XY-foo.cfg drop-ins so that we have a strong ordering guarantee for the final config.

Good catch; I've added sorting. A bit less certain about actually forcing a numeric prefix; just saying they're sorted seems OK for now.

@cgwalters cgwalters enabled auto-merge October 17, 2023 13:20
src/grubconfigs.rs Outdated Show resolved Hide resolved
Currently these are duplicated in osbuild and coreos-assembler.
We will aim to deduplicate them here.

Ideally we'd add support for "day 2" updates of these; I started
on a patch for that but it's sadly messy.

This is an incremental improvement.

Signed-off-by: Colin Walters <[email protected]>
Copy link
Collaborator

@say-paul say-paul left a comment

Choose a reason for hiding this comment

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

Apart from the one general question, LGTM.

Copy link
Member

@jmarrero jmarrero left a comment

Choose a reason for hiding this comment

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

lgtm

@cgwalters cgwalters merged commit 66735ba into coreos:main Oct 19, 2023
6 checks passed
cgwalters added a commit to cgwalters/ignition that referenced this pull request Oct 19, 2023
This pairs with coreos/bootupd#543
Basically we want bootupd to take care of installing this.  Add
the config here (where it more closely arguably belongs) so
that it can be optionally installed.

My proposal for at least the Fedora packaging of Ignition
is that we unconditionally depend on bootupd and install this,
because there's no one there using Ignition who doesn't want bootupd.
jlebon pushed a commit to cgwalters/ignition that referenced this pull request Oct 19, 2023
This pairs with coreos/bootupd#543
Basically we want bootupd to take care of installing this.  Add
the config here (where it more closely arguably belongs) so
that it can be optionally installed.

My proposal for at least the Fedora packaging of Ignition
is that we unconditionally depend on bootupd and install this,
because there's no one there using Ignition who doesn't want bootupd.
cgwalters added a commit to cgwalters/greenboot that referenced this pull request Oct 23, 2023
This pairs with coreos/bootupd#543
to have bootupd support injecting the greenboot grub logic
only if greenboot is installed.
@cgwalters
Copy link
Member Author

xref fedora-iot/greenboot#129

dustymabe added a commit to dustymabe/fedora-coreos-config that referenced this pull request Dec 15, 2023
bootupd upstream was modified to store default static grub configs
and allow for OS integrators to add their own snippets by placing
files in /usr/lib/bootupd/grub2-static/configs.d/ [1] When we move
to building with osbuild we will start taking advantage of this
functionality and calling bootupd with --with-static-configs. Let's
go ahead and add our snippets here so they can be leveraged when we
start calling bootupd with --with-static-configs.

The snippets added here come from the parts of the config currently
defined in coreos-assembler that weren't lifted into bootupd [2][3][4].

[1] coreos/bootupd#543
[2] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L58-L60
[3] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L71-L85
[4] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L87-L91
dustymabe added a commit to dustymabe/coreos-installer that referenced this pull request Dec 15, 2023
Upstream we are starting to use grub configs that are partially
baked into bootupd [1] and partially baked into the image via
the OS vendor (in our case a grub2/50_coreos.cfg file [2]). Let's
look first to see if grub2/50_coreos.cfg exists when trying to
write new console settings before falling back to grub2/grub.cfg.

[1] coreos/bootupd#543
[2] coreos/fedora-coreos-config#2769
dustymabe added a commit to dustymabe/coreos-installer that referenced this pull request Dec 15, 2023
Upstream we are starting to use grub configs that are partially
baked into bootupd [1] and partially baked into the image via
the OS vendor (in our case a grub2/50_coreos.cfg file [2]). Let's
look first to see if grub2/50_coreos.cfg exists when trying to
write new console settings before falling back to grub2/grub.cfg.

[1] coreos/bootupd#543
[2] coreos/fedora-coreos-config#2769
dustymabe added a commit to dustymabe/coreos-installer that referenced this pull request Dec 15, 2023
Upstream we are starting to use grub configs that are partially
baked into bootupd [1] and partially baked into the image via
the OS vendor (in our case a grub2/50_coreos.cfg file [2]). Let's
look first to see if grub2/50_coreos.cfg exists when trying to
write new console settings before falling back to grub2/grub.cfg.

[1] coreos/bootupd#543
[2] coreos/fedora-coreos-config#2769
dustymabe added a commit to dustymabe/coreos-installer that referenced this pull request Dec 15, 2023
Upstream we are starting to use grub configs that are partially
baked into bootupd [1] and partially baked into the image via
the OS vendor (in our case a grub2/30_console.cfg file [2]). Let's
look first to see if grub2/30_console.cfg exists when trying to
write new console settings before falling back to grub2/grub.cfg.

[1] coreos/bootupd#543
[2] coreos/fedora-coreos-config#2769
dustymabe added a commit to dustymabe/fedora-coreos-config that referenced this pull request Dec 15, 2023
bootupd upstream was modified to store default static grub configs
and allow for OS integrators to add their own snippets by placing
files in /usr/lib/bootupd/grub2-static/configs.d/ [1] When we move
to building with osbuild we will start taking advantage of this
functionality and calling bootupd with --with-static-configs. Let's
go ahead and add our snippets here so they can be leveraged when we
start calling bootupd with --with-static-configs.

The snippets added here come from the parts of the config currently
defined in coreos-assembler that weren't lifted into bootupd [2][3][4].

[1] coreos/bootupd#543
[2] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L58-L60
[3] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L71-L85
[4] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L87-L91
dustymabe added a commit to coreos/fedora-coreos-config that referenced this pull request Dec 15, 2023
bootupd upstream was modified to store default static grub configs
and allow for OS integrators to add their own snippets by placing
files in /usr/lib/bootupd/grub2-static/configs.d/ [1] When we move
to building with osbuild we will start taking advantage of this
functionality and calling bootupd with --with-static-configs. Let's
go ahead and add our snippets here so they can be leveraged when we
start calling bootupd with --with-static-configs.

The snippets added here come from the parts of the config currently
defined in coreos-assembler that weren't lifted into bootupd [2][3][4].

[1] coreos/bootupd#543
[2] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L58-L60
[3] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L71-L85
[4] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L87-L91
dustymabe added a commit to dustymabe/fedora-coreos-config that referenced this pull request Jan 5, 2024
bootupd upstream was modified to store default static grub configs
and allow for OS integrators to add their own snippets by placing
files in /usr/lib/bootupd/grub2-static/configs.d/ [1] When we move
to building with osbuild we will start taking advantage of this
functionality and calling bootupd with --with-static-configs. Let's
go ahead and add our snippets here so they can be leveraged when we
start calling bootupd with --with-static-configs.

The snippets added here come from the parts of the config currently
defined in coreos-assembler that weren't lifted into bootupd [2][3][4].

[1] coreos/bootupd#543
[2] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L58-L60
[3] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L71-L85
[4] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L87-L91

(cherry picked from commit b40f727)
dustymabe added a commit to coreos/fedora-coreos-config that referenced this pull request Jan 5, 2024
bootupd upstream was modified to store default static grub configs
and allow for OS integrators to add their own snippets by placing
files in /usr/lib/bootupd/grub2-static/configs.d/ [1] When we move
to building with osbuild we will start taking advantage of this
functionality and calling bootupd with --with-static-configs. Let's
go ahead and add our snippets here so they can be leveraged when we
start calling bootupd with --with-static-configs.

The snippets added here come from the parts of the config currently
defined in coreos-assembler that weren't lifted into bootupd [2][3][4].

[1] coreos/bootupd#543
[2] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L58-L60
[3] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L71-L85
[4] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L87-L91

(cherry picked from commit b40f727)
aaradhak pushed a commit to aaradhak/fedora-coreos-config that referenced this pull request Mar 18, 2024
bootupd upstream was modified to store default static grub configs
and allow for OS integrators to add their own snippets by placing
files in /usr/lib/bootupd/grub2-static/configs.d/ [1] When we move
to building with osbuild we will start taking advantage of this
functionality and calling bootupd with --with-static-configs. Let's
go ahead and add our snippets here so they can be leveraged when we
start calling bootupd with --with-static-configs.

The snippets added here come from the parts of the config currently
defined in coreos-assembler that weren't lifted into bootupd [2][3][4].

[1] coreos/bootupd#543
[2] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L58-L60
[3] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L71-L85
[4] https://github.com/coreos/coreos-assembler/blob/4636b1a5c6dc00b1d6a58b1bfbb199431444336b/src/grub.cfg#L87-L91
djach7 pushed a commit to djach7/greenboot that referenced this pull request Apr 9, 2024
This pairs with coreos/bootupd#543
to have bootupd support injecting the greenboot grub logic
only if greenboot is installed.
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.

4 participants