Amazon Linux 2015.03的自定义内核选项

我一直在试图为CONFIG_HOTPLUG_CPU禁用的2015.03发行版构build一个定制的内核。 在这个论坛和其他地方的一堆线程之后,我已经能够构build一个新的内核RPM,但是我设置的选项没有生效。

到目前为止的步骤是:

 # Download the kernel source /usr/bin/get_reference_source -p kernel-$(uname -r) # Install some needed packages /usr/bin/yum install -y gcc gcc44 system-rpm-config m4 rpm-build gdb xmlto asciidoc elfutils-devel zlib-devel binutils-devel python-devel perl gettext newt-devel perl-ExtUtils-Embed bison audit-libs-devel python27-devel pciutils-devel # Add the mockbuild user which seems to be needed by the kernel source RPM /usr/sbin/useradd mockbuild # Install the source RPM /bin/rpm -Uvh /usr/src/srpm/debug/kernel*.src.rpm # Disable CONFIG_HOTPLUG_CPU /bin/sed -i 's/HOTPLUG_CPU=y/HOTPLUG_CPU=n/' /usr/src/rpm/SOURCES/config* # Set a custom build ID in the spec file /bin/sed -i 's/buildid 31.38/buildid mybuild/' /usr/src/rpm/SPECS/kernel.spec # Build the RPM /usr/bin/rpmbuild -bb /usr/src/rpm/SPECS/kernel.spec # Install the RPM /usr/bin/yum localinstall /usr/src/rpm/RPMS/x86_64/kernel-3.14.42-31.38.tmo.amzn1.x86_64.rpm 

从那里我可以看到新的内核确实在磁盘上可用,但CONFIG_HOTPLUG_CPU仍然被启用:

 $ grep HOTPLUG_CPU= /boot/config-3.14.mybuild* /boot/config-3.14.42-mybuild.amzn1.x86_64:CONFIG_HOTPLUG_CPU=y /boot/config-3.14.42-mybuild.amzn1.x86_64:CONFIG_ACPI_HOTPLUG_CPU=y 

还有什么需要禁用CONFIG_HOTPLUG_CPU并设置新的内核?

我最终通过解压内核源码,编辑configuration选项,重新创buildtarball来解决这个问题。 它看起来像这样:

 # Extract the Kconfig file to change the kernel options /bin/tar xfv /usr/src/rpm/SOURCES/linux-${vanilla_kernel}.tar linux-${vanilla_kernel}/arch/x86/Kconfig # Change the options /bin/sed -i '/ARCH_HIBERNATION_POSSIBLE/!b;n;c\\tdef_bool n' linux-${vanilla_kernel}/arch/x86/Kconfig /bin/sed -i '/ARCH_SUSPEND_POSSIBLE/!b;n;c\\tdef_bool n' linux-${vanilla_kernel}/arch/x86/Kconfig /bin/sed -i '/Support for hot-pluggable CPUs/!b;n;c\t\tdefault n' linux-${vanilla_kernel}/arch/x86/Kconfig # Add the new Kconfig to the tarball # There will now be two of these and the last one wins /bin/tar rf /usr/src/rpm/SOURCES/linux-${vanilla_kernel}.tar linux-${vanilla_kernel}/arch/x86/Kconfig # Change the build id to include our suffix /bin/sed -i 's/\(buildid.*\)/\1\.mybuild/' /usr/src/rpm/SPECS/kernel.spec # Build the new kernel RPM /usr/bin/rpmbuild -bb /usr/src/rpm/SPECS/kernel.spec 

这导致了一组新的RPM,我可以确认CONFIG_HOTPLUG_CPU未启用。