我一直在尝试为 2015.03 版本构建一个CONFIG_HOTPLUG_CPU
禁用的自定义内核。按照本论坛和其他地方的大量帖子,我能够构建一个新的内核 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 并设置新内核还需要什么?
答案1
我最终通过提取内核源代码、编辑配置选项、重新创建 tarball 解决了这个问题。它看起来像这样:
# 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 未启用。