找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
听天命
查看: 878|回复: 2

CentOS 7.X 升级内核

[复制链接]

54

主题

6

回帖

40万

积分

管理员

积分
400064

最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主荣誉管理论坛元老

发表于 2024-4-22 14:40:01 | 显示全部楼层 |阅读模式
查看当前内核版本

  1. uname -a
复制代码
查看当前系统版本

  1. cat /etc/redhat-release
复制代码
1.导入公钥

  1. rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
复制代码
2.1安装CentOS 7.x的ELRepo包

  1. yum install -y https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
复制代码
2.2CentOS 8.x的ELRepo包

  1. yum install -y https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
复制代码
3.下载升级

  1. yum --enablerepo=elrepo-kernel install kernel-ml -y &&
  2. sed -i s/saved/0/g /etc/default/grub &&
  3. grub2-mkconfig -o /boot/grub2/grub.cfg
复制代码
4.重启系统,完成内核升级

回复

使用道具 举报

54

主题

6

回帖

40万

积分

管理员

积分
400064

最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主荣誉管理论坛元老

 楼主| 发表于 2025-8-7 15:13:12 | 显示全部楼层
回复

使用道具 举报

54

主题

6

回帖

40万

积分

管理员

积分
400064

最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主荣誉管理论坛元老

 楼主| 发表于 2025-8-7 15:16:01 | 显示全部楼层
手动下载对应版本的内核软件包并上传到服务器
安装 rpm 包
  1. rpm -ivh kernel-ml-6.3.0-1.el7.elrepo.x86_64.rpm
  2. rpm -ivh kernel-ml-devel-6.3.0-1.el7.elrepo.x86_64.rpm
复制代码

修改 GRUB 中默认的内核版本
  1. [root@vultr ~]# awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2-efi.cfg
  2. 0 : CentOS Linux (6.3.0-1.el7.elrepo.x86_64) 7 (Core)
  3. 1 : CentOS Linux 7 Rescue 853360358a904d2196a5f00ef85dfa7a (3.10.0-1160.88.1.el7.x86_64)
  4. 2 : CentOS Linux (3.10.0-1160.88.1.el7.x86_64) 7 (Core)
  5. 3 : CentOS Linux (3.10.0-1160.83.1.el7.x86_64) 7 (Core)
  6. 4 : CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core)
  7. 5 : CentOS Linux (0-rescue-8007323efcc84eed8641e3343df5577b) 7 (Core)
复制代码

由以上信息可以看出新内核(6.3.0)目前位置在 0,原来的内核(3.10.0)目前位置在 1,所以如果想生效最新的内核,还需要我们修改内核的启动顺序为 0
  1. [root@vultr ~]# grub2-set-default 0
复制代码

运行 grub2-mkconfig 命令来重新创建内核配置
  1. [root@vultr ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
  2. Generating grub configuration file ...
  3. Found linux image: /boot/vmlinuz-6.3.0-1.el7.elrepo.x86_64
  4. Found initrd image: /boot/initramfs-6.3.0-1.el7.elrepo.x86_64.img
  5. Found linux image: /boot/vmlinuz-3.10.0-1160.88.1.el7.x86_64
  6. Found initrd image: /boot/initramfs-3.10.0-1160.88.1.el7.x86_64.img
  7. Found linux image: /boot/vmlinuz-3.10.0-1160.83.1.el7.x86_64
  8. Found initrd image: /boot/initramfs-3.10.0-1160.83.1.el7.x86_64.img
  9. Found linux image: /boot/vmlinuz-3.10.0-1160.el7.x86_64
  10. Found initrd image: /boot/initramfs-3.10.0-1160.el7.x86_64.img
  11. Found linux image: /boot/vmlinuz-0-rescue-853360358a904d2196a5f00ef85dfa7a
  12. Found initrd image: /boot/initramfs-0-rescue-853360358a904d2196a5f00ef85dfa7a.img
  13. Found linux image: /boot/vmlinuz-0-rescue-8007323efcc84eed8641e3343df5577b
  14. Found initrd image: /boot/initramfs-0-rescue-8007323efcc84eed8641e3343df5577b.img
  15. done
复制代码

使用 reboot 命令重启后,查看内核版本
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

精简版|手机版|嗐!无思百忧,祇自重兮 ( 京ICP备18055970号|京ICP备18055970号 )晋公网安备 14010902001813号 劰载中... 本站总访问量次. 您是第个小伙伴

GMT+8, 2026-1-25 15:46 , Processed in 0.098059 second(s), 26 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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