当获取了 RHEL 8.7 kernel source 之后,现在就可以着手build Linux Kernel 并打包成RPM 包了。 什么? 还没有搞到RHEL的kernel source,那得看看这个帖子了。I need Kernel source
编译kernel之前需要安装一些必要的库
- yum groupinstall "Development Tools"
- yum install ncurses-devel
- yum install qt3-devel (This is only necessary if you wish to use make xconfig instead of make gconfig or make menuconfig.)
- yum install hmaccalc zlib-devel binutils-devel elfutils-libelf-devel
配置 kernel config
Change directory to ~/rpmbuild/BUILD/kernel-/linux-/ and copy into this directory, as .config, either the current configuration file from the configs/ directory or the currently running kernel's configuration file, from the /boot/ directory.
[user@host]$ cd ~/rpmbuild/BUILD/kernel-*/linux-*/
Either -
[user@host]$ cp configs/kernel-3.10.0-`uname -m`.config .config
- or -
[user@host]$ cp /boot/config-`uname -r` .config
Build 并生成rpm 包
rpmbuild -bb --target=uname -m kernel.spec 2> build-err.log | tee build-out.log
安装新的Kernel
当build 完成,新build的kernel在 ~/rpmbuild/RPMS/'uname -m'/
Note: The characters around uname -m or uname -r are 'backticks', not apostrophes.
To install all kernel-* packages, run:
[root@host]# rpm -ivh kernel-*.rpm
sudo rpm -ivh kernel-4.18.0-425.3.1.el8.x86_64.rpm
Verifying... ################################# [100%]
Preparing... ################################# [100%]
package kernel-4.18.0-425.13.1.el8_7.x86_64 (which is newer than kernel-4.18.0-425.3.1.el8.x86_64) is already installed
package kernel-4.18.0-425.3.1.el8.x86_64 is already installed