设为首页收藏本站language 语言切换
查看: 2289|回复: 0
收起左侧

Centos8编译安装内核

[复制链接]
发表于 2023-4-25 09:43:27 | 显示全部楼层 |阅读模式

首先下载kernel,5.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配置文件,将下面两行注释掉

#CONFIG_SYSTEM_TRUSTED_KEYS="certs/rhel.pem"#CONFIG_DEBUG_INFO_BTF=y


                               
登录/注册后可看大图


                               
登录/注册后可看大图

然后再次执行make -j $(nproc)

[root@localhost linux-5.10.60]# make -j $(nproc)


                               
登录/注册后可看大图

模块安装,把编译好的模块拷贝到系统目录下

[root@localhost linux-5.10.60]# make modules_install


                               
登录/注册后可看大图

安装二进制内核镜像, 生成并安装boot初始化文件系统映像文件

[root@localhost linux-5.10.60]# make install


                               
登录/注册后可看大图

现在可以查看/lib/modules目录下面多出来一个5.10.60内核的目录了

[root@localhost linux-5.10.60]# ll /lib/modulestotal 8drwxr-xr-x. 6 root root 4096 Apr 11 14:38 4.18.0-305.3.1.el8.x86_64drwxr-xr-x. 3 root root 4096 Apr 11 15:48 5.10.60


                               
登录/注册后可看大图

更新一下grub启动项

[root@localhost linux-5.10.60]# grub2-mkconfig -o /boot/grub2/grub.cfg

查看默认启动项是否是5.10.60

[root@localhost linux-5.10.60]# grubby --default-kernel[root@localhost linux-5.10.60]# grubby --default-index


                               
登录/注册后可看大图

查看所有启动项:

[root@localhost linux-5.10.60]# grubby --info=ALL


                               
登录/注册后可看大图

可使用grubby –set-default 来设置默认启动项。
设置完成之后,可以重启系统,查看是否可以进入系统了。

                               
登录/注册后可看大图


                               
登录/注册后可看大图


您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2025-2-2 20:52 , Processed in 0.064231 second(s), 12 queries , Redis On.  

  Powered by Discuz!

  © 2001-2025 HH010.COM

快速回复 返回顶部 返回列表