1, RPM pre-production environment preparation:
Yum install-y ncurses-devel qt-devel rpm-build redhat-rpm-config asciidoc hmaccalc perl-extutils-embed xmlto audit-libs- Devel binutils-devel elfutils-devel elfutils-libelf-devel newt-devel python-devel zlib-devel BC
2. Prepare the source code component of the kernel
cd/usr/src/
wget-c wget Https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.9.3.tar.xz
TAR-XVF LINUX-4.9.3.TAR.XZ
Ln-s linux-4.9.3 Linux
CD Linux
Make oldconfig # Verify and update configuration. config file (if you only want to modify some small places on the basis of the original kernel configuration) you are basically the default, all the way to the return
Make menuconfig # Simple graphical kernel configuration management, generating a. config file
3. At this point, we can start compiling the new kernel RPM package.
Make rpm # automatically generates RPMTREE,KERNEL.SPEC files, compiles automatically, and generates all RPM package components, including the debug package.
This time we'll wait, or have a cup of afternoon tea or something.
OK, let's find the kernel RPM package that has been compiled.
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/8C/D8/wKiom1h6_YXxheOPAAAPJ0hQQzs668.png "title=" 1.png "alt=" Wkiom1h6_yxxheopaaapj0hqqzs668.png "/>
4. Install the new kernel
RPM-UVH kernel-*-.rpm
5. Reboot to verify kernel version
Uname-a
Second, RPM package depth customization
1, we first create a good rpm "Production workshop" (I think this may be more image).
Yum install rpmdevtools # RPM Production Shop Quick Create tool
useradd-m Builder # Creates a new temporary user to create the RPM package, and if an error occurs, the build program does not break the existing system environment.
Su-builder
Rpmdev-setuptree # Creating a "Production workshop"
The following directory structure will be generated in the builder user's home directory:
Tree-l 1 ~/rpmbuild/
rpmbuild/
├──build
├──rpms
├──sources
├──specs
└──srpms
2. Prepare before compiling
At this point we need to collect the new kernel source package to put in the/home/builder/rpmbuild/sources directory
Su-builder
CD ~/rpmbuild/sources
Wget-c https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.9.3.tar.xz
Note: Rpmbuild is done by gzip to do building before the source package decompression work, so need to convert this compression package into. tar.gz format.
# There's no record here.
cp/boot/config-' Uname-r '. # Copy the existing kernel configuration file config-' Uname-r ' to the SOURCES directory
To switch to the specs directory, generate the Kernel.spec:
Tar jxvf. /sources/linux-4.9.3.tar.xz -C.
Bash.. /linux-4.9.3/scripts/package/mkspec >./kernel.spec
RM-RF linux-4.9.3
# We need to use the script provided in the source package to generate the Kernel.spec file manually
# Remember to clean up the linux-4.9.3 folder after the build Kernel.spec is finished
Vim Kernel.spec # can be customized according to the individual circumstances of the depth
To this, our preparations are basically completed, the directory structure and content are as follows:
Tree Rpmbuild/-A
rpmbuild/
├──build
├──rpms
├──sources
│ ├──config-' Uname-r '
│ └── linux-4.9.3. tar.gz
├──specs
│ └──kernel.spec
└──srpms
5 directories, 3 files
3, OK, now we officially start compiling the kernel binary RPM package:
RPMBUILD-BB--with baseonly--without debug--without debuginfo--target= ' uname-m ' Kernel.spec
Rpmbuild parameter Description:
(1)--with <option> Specifies that a kernel is compiled, and option options are baseonly, Smponly, and Xenonly.
(2)--without <option> Specify the removal of some function modules, optional option has Xen, SMP, Up, PAE, Kdump, Debug and Debuginfo, etc. Where the debug option rejects the debug code in the kernel, the Debuginfo option disables the creation of the Kernel-debuginfo package.
When you are finished, get the RPM installation package in the ~/rpmbuild/rpms/' uname-m '/directory.
This article is from the "Silence" blog, make sure to keep this source http://silencezone.blog.51cto.com/3613477/1892067
How to quickly customize the binary kernel RPM package in Centos