Installing custom kernel on Fedora coreos

I’m trying to install a custom (patched) kernel on Fedora coreos.
I built my kernel as a package “kernel-core-5.16.13-200.nb.fc35” in the usual way with rpmbuild.

No matter what I try, I’m not able to install my custom kernel on coreos, so I must be missing something.

When trying to run:

sudo rpm-ostree override remove kernel kernel-core kernel-modules --replace kernel-5.16.13-200.nb.fc35.x86_64.rpm --replace kernel-core-5.16.13-200.nb.fc35.x86_64.rpm --replace kernel-modules-5.16.13-200.nb.fc35.x86_64.rpm

I’m getting: error: Base packages not marked to be removed: kernel-core, kernel, kernel-modules

When trying to run:

sudo rpm-ostree override replace kernel-5.16.13-200.nb.fc35.x86_64.rpm kernel-core-5.16.13-200.nb.fc35.x86_64.rpm kernel-modules-5.16.13-200.nb.fc35.x86_64.rpm

it actually starts well!

Upgraded:
  kernel 5.16.13-200.fc35 -> 5.16.13-200.nb.fc35
  kernel-core 5.16.13-200.fc35 -> 5.16.13-200.nb.fc35
  kernel-modules 5.16.13-200.fc35 -> 5.16.13-200.nb.fc35
Use "rpm-ostree override reset" to undo overrides
Run "systemctl reboot" to start a reboot

But after reboot, rpm-ostree status shows an error:

State: idle
Warning: failed to finalize previous deployment
         error: Installing kernel: regfile copy: No space left on device
         check `journalctl -b -1 -u ostree-finalize-staged.service`
Deployments:
● fedora:fedora/x86_64/coreos/stable
                   Version: 35.20220313.3.1 (2022-03-28T19:24:40Z)
                    Commit: 4a21b7876e42f223bb70b00eedef698c34a8e72b5ffbfc597aec36f40d149a58
              GPGSignature: Valid signature by 787EA6AE1147EEE56C40B30CDB4639719867C58F

journalctl -b -1 -u ostree-finalize-staged.service shows:

-- Journal begins at Sun 2022-05-15 11:57:57 UTC, ends at Sun 2022-05-15 12:16:10 UTC. --
May 15 12:13:43 nb-qemu systemd[1]: Finished OSTree Finalize Staged Deployment.
May 15 12:13:55 nb-qemu systemd[1]: Stopping OSTree Finalize Staged Deployment...
May 15 12:13:55 nb-qemu ostree[17321]: Finalizing staged deployment
May 15 12:13:59 nb-qemu ostree[17321]: Copying /etc changes: 14 modified, 0 removed, 36 added
May 15 12:13:59 nb-qemu ostree[17321]: Copying /etc changes: 14 modified, 0 removed, 36 added
May 15 12:14:01 nb-qemu ostree[17321]: error: Installing kernel: regfile copy: No space left on device
May 15 12:14:01 nb-qemu systemd[1]: ostree-finalize-staged.service: Control process exited, code=exited, status=1/FAILURE
May 15 12:14:01 nb-qemu systemd[1]: ostree-finalize-staged.service: Failed with result 'exit-code'.
May 15 12:14:01 nb-qemu systemd[1]: Stopped OSTree Finalize Staged Deployment.
May 15 12:14:01 nb-qemu systemd[1]: ostree-finalize-staged.service: Consumed 2.378s CPU time.

  • Why does rpm-ostree override remove --replace fails where rpm-ostree override replace seems to work?
  • Am I missing something with rpm-ostree? Should I run it differently?
  • Must I increase the boot partition to install a custom kernel?? How do I do that on coreos?

Eventually my goal is to perform this kernel update in an ignition script so I could use an off-the-shelf coreos image and replace its kernel on the first boot.

I would appreciate your advice!

1 Like
error: Installing kernel: regfile copy: No space left on device

This is likely due to /boot being full or not being large enough to accommodate your kernel.

1 Like

Increasing the boot partition size, from what I read, is a complicated and unsupported procedure so I would like to avoid it.

The other option is to remove the old kernel, but it does not work:

sudo rpm-ostree override replace --remove=kernel --remove=kernel-core --remove=kernel-modules --install=kernel-core-5.16.13-200.nb.fc35.x86_64.rpm --install=kernel-modules-5.16.13-200.nb.fc35.x86_64.rpm kernel-5.16.13-200.nb.fc35.x86_64.rpm

returns an error: error: Base packages not marked to be removed: kernel-core, kernel, kernel-modules

It really makes no sense to me…
Any idea?

rpm-ostree does not operate on existing deployments by default and thus your remove operation will only affect the next deployment.

What you probably want to do instead is to remove all deployments except the current one to free up space in /boot:

$ rpm-ostree cleanup -brpm

Thanks @siosm for the suggestion, but this still doesn’t work.

When running rpm-ostree cleanup -brpm as you suggested, it seems to remove the newly installed kernel so I’m still with the old kernel after reboot.

If I run this cleanup before running rpm-ostree override replace it does not free up space under /boot and I still get the same error: Installing kernel: regfile copy: No space left on device.

Any other idea how to solve this?

You can try building a smaller kernel package or create a larger /boot partition.

I’m actually building a fedora stock kernel (kernel-5.16.13-200.fc35.src.rpm) with a small patch.
I’m building it with:

rpmbuild -bb --with baseonly --without debuginfo --target=x86_64 kernel.spec

So I don’t expect my kernel package to be any bigger than the kernel that is already used naturally by coreos.

Regarding a larger /boot partition - any pointers about that?
I’m using ignition script so I would like to configure that there, but I’m not sure how.

Should I use boot_device configuration? From the docs it seems to be used only for luks or mirroring, not for what I’m trying to do.

Let’s keep the discussion in one place in Cannot install custom kernel package · Issue #1196 · coreos/fedora-coreos-tracker · GitHub