首先下载kernel,5.x或者6.x版本的内核。
下载地址:https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/
系统安装相关包:
# yum install -y bc gcc make python3 ncurses-devel flex bison openssl-devel elfutils-libelf-devel
将内核解压
[root@localhost ~]# tar xvf linux-5.10.60.tar.xz
[root@localhost linux-5.10.60]# cd linux-5.10.60
使用现有的config文件
[root@localhost linux-5.10.60]# cp -p /boot/config-4.18.0-305.3.1.el8.x86_64 .config
使用老的配置参数
[root@localhost linux-5.10.60]# sh -c 'yes ""| make oldconfig'
Make编译,使用nproc命令表示使用所有cpu线程:
[root@localhost linux-5.10.60]# make -j $(nproc)
Make 报错:
make[1]: *** No rule to make target 'certs/rhel.pem', needed by 'certs/x509_certificate_list'. Stop.
和这个报错Failed to generate BTF for vmlinux
编辑.config配置文件,将下面两行注释掉