Any experience building custom linux kernel?

I’m interested in building a custom kernel for Fedora Silverblue. However, I am not able to find any decent resources that consider this situation and explain how things change due to the way Silverblue works with the boot loader and all.

Has anyone tried building a custom kernel? Do you have any pointers, documentation, etc.?

Are you rebuilding just the kernel or do you want to change other fundamental things?

The Fedora Silverblue kernel is the same as the rest of Fedora. So building it the same way should work. Re. the bootloader, there’s nothing special other than (1) making sure you’re using a supported bootloader (grub2, uboot, syslinux, or anything that supports BLS), and (2) keeping /boot a separate partition. For information on boot integration, one resource is https://ostree.readthedocs.io/ though you’ll probably want to look directly at how things are wired in Silverblue (or Fedora CoreOS) too as a practical example.

I’ll explain my primary intention. Hopefully that gives you all the information you need.

I would like to build a vanilla kernel with mostly the same configuration as Fedora, with most tweaks mostly being disabling stuff I really don’t need. (Drivers etc.) Why I’d need to build a kernel is the BMQ scheduler patches.

On a regular Fedora installation, I would simply build and then install using sudo make install. However, on Silverblue, I wanted to check first to be sure before messing up the system. :slight_smile:

I’ll have a look at the ostree link you posted. Thanks!

Did you get your custom kernel build working on Silverblue @cobratbq ?

I’m looking to do something similar and I wonder if you could share notes.

I decided not to continue. Silverblue’s structure seemed quite different from what the kernel scripts assume and I would rather spend my time getting to know Silverblue’s potential as is. Instead of spending a massive amount of time on the kernel. The thing is, you would have to bend the process into weird curves only because it isn’t part of the base image.

The easiest way to change the kernel on Silverblue / CoreOS / Kinoite / IoT (rpm-ostree based Fedora), is to build an RPM with your changes and then use:

$ sudo rpm-ostree override replace ./kernel*.rpm

Some links to get started:

Thanks for that. This would cover the install step for sure.

I got stuck pretty early following the “Building a Custom Kernel” docs. Here is what I wrote at the time about it:

I’m looking to test out a bugfix and need to build a fedora kernel with some code changes made to it. It shouldn’t matter which specific version I build (could be vanilla, or latest F34 kernel, I don’t mind).

What matters to me is being able to have some sort of edit/debug cycle: change code, build rpms, install, test, repeat.

I’ve looked at the quick docs instructions ( Redirect Notice ) and have a couple of questions:

  1. If I try the “exploded git trees” method, then from what I can see there is no F34 branch available.
  2. If I try the “fedora dist-git” method, I can build my local RPMs just fine, but it’s not clear to me how I go about editing code. Can I just edit the code that’s been downloaded into kernel-5.14-rc7/linux-5.14.0-0.rc7.54.paul.fc36.x86_64/ then rebuild? (It looks like the scripts generate that code by extracting tarballs then applying patches on top. It’s not clear I can just go and edit it.)

The “exploded git tree” kernel now lives in GitLab:

The wiki & docs pages need an update indeed.

Thanks for those! I managed to get my kernels built using the Fedora/ARK Kernel resources.

I ended up doing the build on F34 workstation (as that machine is faster than my silverblue one), so cannot explicitly confirm that the instructions would work for silverblue. However the rpm packages I built installed fine on SB using rpm-ostree override replace.

1 Like