快速升级CentOS/RHEL内核

之前写过一篇源码编译安装内核的文章CentOS下编译Linux内核_巭犇的博客-CSDN博客_centos 编译内核

本文介绍如何借用已有的内核快速进行内核升级

主要步骤为,下载已编译好的内核----->将新的内核文件设置为默认内核。

本文使用ELRepo网站所提供的软件仓库,网站连接为ELRepo | HomePage这是一个企业 Linux 软件包的 RPM 存储库。 ELRepo 支持 Red Hat Enterprise Linux (RHEL) 及其重建项目。

1、导入公钥

[root@ct7_node04 ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

2、安装对应操作系统版本的软件仓库,本文以CentOS7为例

[root@ct7_node04 ~]# yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm

ELRepo包含四个小的软件仓库,分别为elrepo、elrepo-testing、elrepo-kernel、elrepo-extras,默认启用的是elrepo,升级内核需要用到的是elrepo-kernel,关于这四个仓库的详细介绍可参考官网ELRepo | HomePage

elrepo-kernel介绍

elrepo-kernel 仓库提供长期支持版的内核和最新的稳定版本的内核,原文如下

The elrepo-kernel channel provides both the long-term support kernels (which have been configured for RHEL-7 ) and the latest stable mainline kernels (which have been configured for RHEL-8 and RHEL-7) using sources available from the Linux Kernel Archives. Please see the kernel-lt or kernel-ml pages for further details. This channel may be enabled in the /etc/yum.repos.d/elrepo.repo file or used with 'yum --enablerepo=elrepo-kernel'.

3、查看elrepo-kernel所提供的内核版本

[root@ct7_node04 ~]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available

内核版本介绍:
lt :longterm的缩写:长期维护版;
ml :mainline的缩写:最新稳定版;

4、安装所需的内核版本

[root@ct7_node04 ~]# yum --enablerepo=elrepo-kernel install kernel-lt -y
安装成功后会在/boot/目录下看到刚刚下载的新版本内核文件和initramfs文件。

5、修改内核的启动顺序

  1.  修改grub的配置文件,使用最新版本的内核
    [root@ct7_node04 ~]# cat /etc/default/grub
    GRUB_TIMEOUT=5
    GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
    GRUB_DEFAULT=0               //此处修改为0,代表使用最新版本内核
    GRUB_DISABLE_SUBMENU=true
    GRUB_TERMINAL_OUTPUT="console"
    GRUB_DISABLE_RECOVERY="true"
    GRUB_CMDLINE_LINUX="biosdevname=0 net.ifnames=0 console=ttyS0,115200n8"
    GRUB_DISABLE_LINUX_UUID="true"
    GRUB_ENABLE_LINUX_LABEL="true"
    
  2. 生成grub文件,替换原来的文件
    [root@ct7_node04 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg 
    

6、重启验证是否升级成功 

[root@ct7_node04 ~]# uname -r
3.10.0-514.el7.x86_64        //之前的版本


[root@ct7_node04 ~]# uname -r
5.4.202-1.el7.elrepo.x86_64  //当前版本

已成功升级

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值