Rebuilding kernel RPMs with altered config [Rocky 9]

Hi all,

I need to slightly change the kernel(-rt) config and rebuild the RPMs.

That worked fine for Rocky 8 but I somehow fail to accomplish this with Rocky 9.
After I adapted the config, I can build the RPMs but the changes are not there.

What I did is the following (as non-root user)

Get and install the sources from

In the rpmbuild/SPECS/ directory I issue

rpmbuild -bp --target=$(uname -m) kernel.spec

which sets up the tree at


There, at


I copy over

cp configs/kernel-rt-5.14.0-x86_64.config .config

and issue

  make oldconfig
  make menuconfig

Applying my changes, saving the config and adding

# x86_64

to the top of it, I copy it back to




Finally, in SPECS, building the RPMs with

rpmbuild -bb --with baseonly --clean --target=$(uname -m) kernel.spec 2> build-err.log | tee build-out.log

This finishes without build issues, but, as I said, when I install it, the config is just the standard one,
missing all my changes.

What’s the correct way of doing this?
Tried to follow the spec file and find out what’s wrong but I got lost.

Grateful for any help.
Thanks in advance.

There were a fair number of changes in the EL8 and EL9 kernel spec files, so it’s not overly surprising that this happens. I believe the spec reconfigures some options, and it could be that it is overriding your changes.

I would recommend checking out the kernel spec file and trying to search around for the options you are enabling. It is likely that there are flags which will configure the kconfig in the way you’re looking for.

Additionally, I’d recommend using mock to rebuild the RPMs. it is what we use to build them initially, and there are mock configs to use our development repositories available as part of the package (in epel/fedora)

Hope this helps!

1 Like

Thanks Neil for your help and the hint pointing to mock.
As soon as I find the time, I’ll look into that approach.

In case it may be of help to others, for the time being,
I managed to build an RPM package with a slightly adapted
hacky approach from what is outlined above.


make oldconfig
make menuconfig

I used vimdiff to manually put/update all relevant CONFIG_* fields in


from the generated


but omitted

CONFIG_CC_VERSION_TEXT=“gcc (scripts/dummy-tools/gcc)”

N.B. Copying the file and restoring CONFIG_CC_VERSION_TEXT did
not work, as there were other (required) fields set in the packaged .config
that must not be dropped.

Afterwards copy configs/kernel-rt-5.14.0-x86_64.config to


and proceed with the steps as outlined.

1 Like