Skip to content

bootc: support grub2 serial console customization#2403

Open
jbtrystram wants to merge 3 commits into
osbuild:mainfrom
jbtrystram:blueprint_add_bootloader_grub_options
Open

bootc: support grub2 serial console customization#2403
jbtrystram wants to merge 3 commits into
osbuild:mainfrom
jbtrystram:blueprint_add_bootloader_grub_options

Conversation

@jbtrystram

Copy link
Copy Markdown
Contributor

Wire the blueprint bootloader customization into the bootc disk image pipeline.
When blueprint specifies grub2 serial/terminal settings, emit an org.osbuild.grub2.d stage that writes a drop-in config to boot/grub2/console.cfg after bootc install-to-filesystem.

This relies on bootupd's console.cfg grub config: https://github.com/coreos/bootupd/blob/main/src%2Fgrub2%2Fgrub-static-pre.cfg#L41

This adds a Go wrapper for the new osbuild stage and reads GetBootloader() in the bootc image type.

Assisted-by: Opencode.ai <Opus 4.6>
Requires: osbuild/blueprint#53
Requires: osbuild/osbuild#2473

@jbtrystram
jbtrystram requested a review from a team as a code owner June 8, 2026 07:46
@jbtrystram
jbtrystram force-pushed the blueprint_add_bootloader_grub_options branch 2 times, most recently from 9d7b50c to b1afdd7 Compare June 8, 2026 09:58
@supakeen
supakeen self-requested a review June 8, 2026 13:20
@supakeen
supakeen marked this pull request as draft June 8, 2026 13:20
@supakeen

supakeen commented Jun 8, 2026

Copy link
Copy Markdown
Member

@jbtrystram I'll mark this one as draft until we land the required osbuild stage in main so we can run CI in a useful manner 🙂

@jbtrystram

jbtrystram commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@supakeen I see the blueprints changes have been released so I guess this can be reviewed ?

I just noticed the image-builder-cli repo merge and haven't built the cli with the new sources so haven't re-tested this since the rebase.

@supakeen

supakeen commented Jul 9, 2026

Copy link
Copy Markdown
Member

@supakeen I see the blueprints changes have been released so I guess this can be reviewed ?

I just noticed the image-builder-cli repo merge and haven't built the cli with the new sources so haven't re-tested this since the rebase.

Yea, you can undraft.

@jbtrystram
jbtrystram marked this pull request as ready for review July 9, 2026 05:25
supakeen
supakeen previously approved these changes Jul 9, 2026

@joelcapitao joelcapitao left a comment

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 tested this PR alongside other PRs I have and got:

============================================================
=== Processing artifact: qemu for x86_64
============================================================
IMAGE_TYPE: qcow2
MEDIA_TYPE: application/vnd.diskimage.qcow2
=== Pre-merged blueprint for qemu ===
name = "Fedora CoreOS"
 
[customizations]
 
[customizations.ignition]
 
[customizations.ignition.firstboot]
empty = true
 
[customizations.kernel]
append = "mitigations=auto,nosmt $ignition_firstboot ignition.platform.id=qemu console=tty0 console=ttyS0,115200n8"
 
[customizations.bootloader]
 
[customizations.bootloader.grub2]
terminal_input = ["serial", "console"]
terminal_output = ["serial", "console"]
serial = "serial --speed=115200"
=== Building qemu disk image ===
Manifest generation step
Building manifest for bootc-based-qcow2
Using disk.yaml root filesystem (xfs), ignoring bootc config (xfs)
Image building step
<stdin> has errors:
 
.pipelines[2].stages[7].options:
  'path' is a required property
 
error: error running osbuild: exit status 2
ERROR: Failed to build qemu

from https://konflux-ui.apps.kflux-fedora-01.84db.p1.openshiftapps.com/ns/coreos-tenant/applications/fedora-coreos-rawhide/pipelineruns/disk-images-rawhide-pull-request-8gbz6

Comment thread pkg/manifest/raw_bootc.go
@jbtrystram
jbtrystram force-pushed the blueprint_add_bootloader_grub_options branch from 80612a9 to cb7d8ac Compare July 9, 2026 13:45
@jbtrystram
jbtrystram requested a review from supakeen July 9, 2026 13:45
@jbtrystram
jbtrystram force-pushed the blueprint_add_bootloader_grub_options branch from cb7d8ac to 90ca81e Compare July 9, 2026 13:48
supakeen
supakeen previously approved these changes Jul 10, 2026

@supakeen supakeen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mmm I still had the default path value in my head too :)

@brlane-rht
brlane-rht force-pushed the blueprint_add_bootloader_grub_options branch from 90ca81e to 7e81b82 Compare July 14, 2026 22:29

@brlane-rht brlane-rht left a comment

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.

This needs tests. I also like to see separate commits for changes to the different pkg/* subdirectories.

@jbtrystram
jbtrystram force-pushed the blueprint_add_bootloader_grub_options branch from 7e81b82 to f58fa24 Compare July 16, 2026 13:22
@jbtrystram
jbtrystram requested a review from achilleas-k as a code owner July 16, 2026 13:22
Add Go types and constructor for the org.osbuild.grub2.d stage which
writes a GRUB2 drop-in configuration file at a configurable path.

Include a converter NewGrub2DConfigFromGrub2Config() that extracts
console-related fields (terminal_input, terminal_output, serial) from
the existing GRUB2Config type.

Requires: osbuild/osbuild#2473

Authored-by: Opencode.ai <claude-opus-4-6@default>
@jbtrystram
jbtrystram force-pushed the blueprint_add_bootloader_grub_options branch from f58fa24 to a354f0b Compare July 16, 2026 13:54
@jbtrystram

Copy link
Copy Markdown
Contributor Author

This needs tests. I also like to see separate commits for changes to the different pkg/* subdirectories.

I added tests and split the PR into 3 commits.

When OSCustomizations.Grub2Config has console-related settings
(terminal_input, terminal_output, serial), emit an org.osbuild.grub2.d
stage that writes a drop-in config to boot/grub2/console.cfg.

This uses bootupd mounts (like the ignition stage) because the config
must be written to /boot after bootc install-to-filesystem.

This relies on bootupd's console.cfg grub config:
https://github.com/coreos/bootupd/blob/main/src/grub2/grub-static-pre.cfg#L41

Authored-by: Opencode.ai <claude-opus-4-6@default>
Read blueprint bootloader.grub2 settings (terminal_input,
terminal_output, serial) and pass them as a GRUB2Config to the
raw_bootc pipeline, which emits the grub2.d stage.

Add 'customizations.bootloader' to the supported options list for
bootc disk image types so blueprint validation accepts it.

Requires: osbuild/blueprint#53

Authored-by: Opencode.ai <claude-opus-4-6@default>
@jbtrystram
jbtrystram force-pushed the blueprint_add_bootloader_grub_options branch from a354f0b to 6bc677d Compare July 16, 2026 14:02
@supakeen
supakeen requested review from brlane-rht and supakeen July 16, 2026 16:03

@thozza thozza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks. Except for my inline comments, everything looks nice. Those are minor and can be a follow-up.

Path string `json:"path"`

// GRUB2 configuration to write
Config *Grub2DConfig `json:"config"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nitpick: this doesn't need to be a pointer, since config is a required stage option. It should never be omitted and null is not a valid value for the stage options schema.

Comment on lines +25 to +30
func NewGrub2DStage(options *Grub2DStageOptions) *Stage {
return &Stage{
Type: "org.osbuild.grub2.d",
Options: options,
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The options.Path values could have been checked against the same regexes as those defined in the stage schema.

@brlane-rht brlane-rht left a comment

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.

Ack

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.

5 participants