# Rebuilding kernel RPMs with altered config \[Rocky 9\]

**URL:** <https://forums.rockylinux.org/t/rebuilding-kernel-rpms-with-altered-config-rocky-9/7395>\
**Category:** Rocky Linux Help & Support\
**Created:** [September 29, 2022, 10:00am UTC](https://forums.rockylinux.org/t/rebuilding-kernel-rpms-with-altered-config-rocky-9/7395 "2022-09-29T10:00:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![milo](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/milo/32/1808_2.png) [@milo](https://forums.rockylinux.org/u/milo)\
**Post date:** [September 29, 2022, 10:00am UTC](https://forums.rockylinux.org/t/rebuilding-kernel-rpms-with-altered-config-rocky-9/7395/1 "2022-09-29T10:00:54Z")

</div>

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

[http://dl.rockylinux.org/pub/rocky/9/RT/source/tree/Packages/k/kernel-rt-5.14.0-70.26.1.rt21.98.el9.src.rpm](http://dl.rockylinux.org/pub/rocky/9/RT/source/tree/Packages/k/kernel-rt-5.14.0-70.26.1.rt21.98.el9.src.rpm)

In the rpmbuild/SPECS/ directory I issue

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

which sets up the tree at

`~/rpmbuild/BUILD/kernel-5.14.0-70.26.1.rt21.98.el9_0`

There, at

`~rpmbuild/BUILD/kernel-5.14.0-70.26.1.rt21.98.el9_0/linux-5.14.0-70.26.1.rt21.98.el9.x86_64`

I copy over

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

and issue

```auto
  make oldconfig
  make menuconfig

```

Applying my changes, saving the config and adding

`# x86_64`

to the top of it, I copy it back to

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

and

`~rpmbuild/SOURCES/kernel-rt-x86_64.config`

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.

---

<div class="post-metadata">

**Author:** ![neil](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/neil/32/34_2.png) [@neil](https://forums.rockylinux.org/u/neil)\
**Post date:** [September 29, 2022, 4:07pm UTC](https://forums.rockylinux.org/t/rebuilding-kernel-rpms-with-altered-config-rocky-9/7395/2 "2022-09-29T16:07:00Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![milo](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/milo/32/1808_2.png) [@milo](https://forums.rockylinux.org/u/milo)\
**Post date:** [October 4, 2022, 9:18am UTC](https://forums.rockylinux.org/t/rebuilding-kernel-rpms-with-altered-config-rocky-9/7395/3 "2022-10-04T09:18:01Z")

</div>

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.

After

```auto
make oldconfig
make menuconfig

```

I used vimdiff to manually put/update all relevant CONFIG\_\* fields in

> configs/kernel-rt-5.14.0-x86\_64.config

from the generated

> .config

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

> …/…/…/SOURCES/kernel-rt-x86\_64-rhel.config

and proceed with the steps as outlined.

---

<div class="post-metadata">

**Author:** ![brian](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/brian/32/5777_2.png) [@brian](https://forums.rockylinux.org/u/brian)\
**Post date:** [August 25, 2023, 3:38am UTC](https://forums.rockylinux.org/t/rebuilding-kernel-rpms-with-altered-config-rocky-9/7395/4 "2023-08-25T03:38:34Z")

</div>


