With more and more Linux servers, the underlying system kernel wants to keep the version unified and needs to customize a dedicated binary installation package for easy upgrade and management. Redhat is of course the use of Rpmbuild to do custom management.
Today we have two sections (root and normal user) to explain how to make a kernel binary RPM package.
Building host system Environment conventions:
-
Os:centos Release 6.6
-
arch:i686
The first part, RPM package simple customization
Note: Here we first have to reserve at least 20GB of temporary file space.
First, RPM preparation of the environment before:
yum -y groupinstall "Development Tools"
yum -y install ncurses-devel qt-devel
yum -y install rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed xmlto
yum -y install audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-devel
yum -y install newt-devel python-devel zlib-devel bc
Second, prepare the source code component of the kernel
cd / usr / src
wget -c https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.1.tar.xz
tar -Jxvf linux-3.19.1.tar.xz
ln -s linux-3.19.1 linux
cd linux
make oldconfig # Verify and update the configuration .config configuration file (if you only want to modify some small places based on the original kernel configuration)
make menuconfig # Simple graphical kernel configuration management
Third, at this point, we can start to compile 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.
cd /root/rpmbuild/RPMS/`uname -m`/
tree RPMS/
RPMS/
└── i386
├── kernel-3.19.1-2.i386.rpm
├── kernel-devel-3.19.1-2.i386.rpm
└── kernel-headers-3.19.1-2.i386.rpm
1 directory, 3 files
Iv. installation of the new kernel
RPM-UVH kernel-*-.rpm
V. Reboot, verify kernel version
The second part, RPM package depth customization
First, we create a good rpm "Production workshop" (I think this may be more image).
yum install rpmdevtools # rpm production workshop quick creation tools
useradd -m builder # Create a new temporary user to create RPM packages. If an error occurs, the builder will not destroy the existing system environment.
su-builder
rpmdev-setuptree # Create "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
Second, pre-compilation preparation
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://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.1.tar.xz
cp / boot / config-`uname -r` .config # Copy the existing kernel configuration file config to the SOURCES directory
Third, switch to specs directory, start building kernel
tar Jxvf ../SOURCES/linux-3.19.1.tar.xz
bash ../linux-3.19.1/scripts/package/mkspec> ./ kernel.spec # Generate kernel.spec file
rm -rf linux-3.19.1
vim kernel.spec # can be customized in depth according to personal circumstances
rpmbuild -bb --with baseonly --without debug --without debuginfo --target = `uname -m` kernel.spec
# --with <option> indicates to compile a certain kernel. The available options are baseonly, smponly, and xenonly.
# --without <option> indicates that some functional modules are removed. The available options are xen, smp, up, pae, kdump, debug, and debuginfo.
# Among them, the debug option will remove the debug code from the kernel, and the debuginfo option will prevent the establishment of the kernel-debuginfo package.
When you are finished, get the RPM installation package in the ~/rpmbuild/rpms/' uname-m '/directory.
--------------------------------------------------------------------------------------------------------------- ------------
RPM Package Building Reference Documentation:
Http://fedoraproject.org/wiki/How_to_create_an_RPM_package/zh-cn
Http://fedoraproject.org/wiki/Building_a_custom_kernel
http://wiki.centos.org/zh/HowTos/Custom_Kernel#head-981e27f326384c58516d3b2051b225526bb0a50a
- This article is from: Linux Tutorial Network
How does the Red Hat series quickly customize the binary kernel RPM package?