CentOS6: Building A Modified Kernel Rpm

Home » CentOS » CentOS6: Building A Modified Kernel Rpm
CentOS 5 Comments

I’m very confused on the right step to use to setup a modified kernel in CentOS6.

As a simple user, I’ve downloaded the latests sources (I’m runing an old kernel version) :

rpm -i http://vault.CentOS.org/6.7/updates/Source/SPackages/kernel-2.6.32-573.22.1.el6.src.rpm

in the spec file ~/rpmbuild/SPECS/kernel.spec I’ve set:
%define buildid .numa

Now I want to set *CONFIG_NUMA_EMU=y*
before runing:
rpmbuild -bb –without xen –without debug –without debuginfo –target=x86_64
./SPECS/kernel.spec

But where shoud I set this CONFIG_NUMA_EMU option ?
I’ve tested several config files where this options was specified (using grep as a last solution) but each build reset my choice and it is not available in the final kernel.

And google is a little bit confusing for me with many and many diverging informations.

Thank to kernel gourous for their advices.

Patrick

5 thoughts on - CentOS6: Building A Modified Kernel Rpm

  • Akemi Yagi wrote:
    Thanks for answering Akemi . Indeed I tried using this howto before posting but something is wrong in this tutorial.

    I installed the prerequisites and downloaded the kernel sources as detailed in section 2 of https://wiki.CentOS.org/HowTos/I_need_the_Kernel_Source.

    But on https://wiki.CentOS.org/HowTos/Custom_Kernel, section 2, all goes wrong!
    My ~/rpmbuild/BUILD directory is empty!
    No configs directory too. No ~/rpmbuild/BUILD/kernel-*/linux-*/ available, all configs files are in
    ~/rpmbuild/SOURCES

    Since this I try to modify ~/rpmbuild/SOURCES/config-x86-generic because it was the only file containing the CONFIG_ACPI_NUMA flag. No success, the build does not take account of my changes as the
    ~/rpmbuild/BUILD/kernel-2.6.32-573.22.1.el6/linux-2.6.32-573.22.1.el6.numa.x86_64/.config created file with:
    rpmbuild -bb –without xen –without debug –without debuginfo –target=x86_64
    ./SPECS/kernel.spec says “# CONFIG_NUMA_EMU is not set”

    So I change this file with an editor and rebuild the rpm package of the kernel with the same command. The .config file is overwriten.

    Today I’ve founded the “Howto Rebuild CentOS 6.0 Linux Kernel” page of Vaidas Jablonskis
    (https://jablonskis.org/2011/howto-rebuild-CentOS-6-0-linux-kernel/index.html)

    rpm -i http://vault.CentOS.org/6.7/updates/Source/SPackages/kernel-2.6.32-573.22.1.el6.src.rpm edit ~/rpmbuild/SPECS/kernel.spec to set the buildid rpmbuild -bp ~/rpmbuild/SPECS/kernel.spec cd
    ~/rpmbuild/BUILD/kernel-2.6.32-573.22.1.el6/linux-2.6.32-573.22.1.el6.numa.x86_64/
    edit .config or make menuconfig to set CONFIG_NUMA_EMU=y make rpm

    But compilation fails with arch/x86/mm/srat_64.c: In function ‘acpi_fake_nodes’:
    arch/x86/mm/srat_64.c:469: error: implicit declaration of function
    ‘__acpi_map_pxm_to_node’

    An error i’ve met some years ago and the only work arround found was to use an older kernel source package.

    Patrick
    ||

  • The referenced wiki article should work for building CentOS-6 kernels (not quite ready for CentOS-7). You really have to dot the i’s and cross the t’s. If you miss a step or command in there, chances are it will fail.

    As you found out, editing the existing config-x86-generic file would not work because the final config file is created on the fly. This is why the wiki instructions tell you to create your customized config file and show you how to get that config file to be used during the build process.

    I have another suggestion for you. Get the srpm for the CentOSPlus kernel instead of the distro kernel. The plus kernel is a customized kernel. It has kernel-xx-config files that you can directly edit. They will not be overwritten. Perhaps this method is easier.

    But if you wish to go for the original method, just be extremely precise not to skip any step.

    Hope this helps,

    Akemi

  • Dear Akemi,

    I’m really ashamed, in “https://wiki.CentOS.org/HowTos/I_need_the_Kernel_Source”
    I’ve missed the last 5 lines following the CentOS5 section. All is now clear for me on the process to follow to build a new kernel from source rpm and the CONFIG_NUMA_EMU option is active. I’ve set it with make menuconfig to avoid some additional mistakes in the config file.

    However, with this CONFIG_NUMA_EMU option , the compiler returns an error and compilation fails. arch/x86/mm/srat_64.c: In function ‘acpi_fake_nodes’:
    arch/x86/mm/srat_64.c:469: error: implicit declaration of function
    ‘__acpi_map_pxm_to_node’
    make[2]: *** [arch/x86/mm/srat_64.o] Error 1
    make[1]: *** [arch/x86/mm] Error 2
    make: *** [arch/x86] Error 2
    make: *** Waiting for unfinished jobs…. error: Bad exit status from /var/tmp/rpm-tmp.VkJ805 (%build)
    Bad exit status from /var/tmp/rpm-tmp.VkJ805 (%build)

    Without CONFIG_NUMA_EMU option, compilation is successfull. It is the CentOSplus kernel from kernel-2.6.32-573.el6.CentOS.plus.src.rpm as yous suggested.

    Thank for your patience

    Patrick

    Akemi Yagi wrote:

  • Patrick Begou wrote:

    Redhat make very big changes to the base kernel source to create their kernel – meaning that code they don’t use (i.e. code included with CONFIG options they don’t support) may no longer build – as is probably the case here

    You may want to compare the 2.6.32-573 source with the generic 2.6.32
    kernel source where your compile fails above to see if you can find a workaround

    A useful starting point could be:

    http://lxr.free-electrons.com/ident?v=2.6.32;i=__acpi_map_pxm_to_node

    However, there is no guarantee that even if you get it to compile that it will work as expected …

    James Pearson