首页 > 系统相关 >linux内核离线升级步骤详解【亲测可用】

linux内核离线升级步骤详解【亲测可用】

时间:2022-09-30 11:45:26浏览次数:49  
标签:x86 linux 离线 64 内核 Linux root el7 亲测

由于种种原因,linux的内核版本需要升级,但由于生产原因往往不能在线升级,在此记录笔者本人昨晚的的离线升级步骤,亲测可用。
我们知道,红帽和CentOS同源同宗,内核升级步骤也是一样的。

目录

■ Red Hat / CentOS 7最新内核下载

内核版本 5.4.214 于 2022-9-18 发布,lt 是指长期支持版本 long term

wget https://mirrors.aliyun.com/elrepo/kernel/el7/x86_64/RPMS/kernel-lt-5.4.214-1.el7.elrepo.x86_64.rpm --no-check-certificate

在以上地址可以下载各个版本的内核,再次向阿里云、网易、163、清华等这些开源镜像提供者致敬,不愧大家风范,方便了国内用户对开源软件的使用。

■ 内核安装

yum localinstall kernel-lt-5.4.214-1.el7.elrepo.x86_64.rpm
可能有包依赖关系,视情况配置yum源,或下载指定包

■ 此时查看所有的内核

awk -F\' '$1=="menuentry " {print i++ " : " $2}' /boot/grub2/grub.cfg
---【Red Hat】输出类似如下:
0 : Red Hat Enterprise Linux Server (5.4.214-1.el7.elrepo.x86_64) 7.3 (Maipo)
1 : Red Hat Enterprise Linux Server (3.10.0-514.el7.x86_64) 7.3 (Maipo)
2 : Red Hat Enterprise Linux Server (0-rescue-13fa607805964427bb4a2297f3619e6e) 7.3 (Maipo)
---【CentOS】输出类似如下:
0 : CentOS Linux (5.4.214-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-1160.15.2.el7.x86_64) 7 (Core)
2 : CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
3 : CentOS Linux (0-rescue-6d425900e59b4ef18c98680ce9a348dd) 7 (Core)

可见已有多个内核,包括原内核 1 与新安装的内核 0

■ 内核配置

新内核安装后,需修改os已有的内核启动顺序,默认启动的顺序应该为1,升级以后内核是往前面插入为0,则需设置GRUB_DEFAULT=0。
默认的配置文件 /etc/default/grub ,参数 GRUB_DEFAULT=saved

vim /etc/default/grub
GRUB_DEFAULT=saved
需改为:
GRUB_DEFAULT=0

■ 重新生成grub配置文件

grub2-mkconfig -o /boot/grub2/grub.cfg
---输出类似如下:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.214-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-5.4.214-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-13fa607805964427bb4a2297f3619e6e
Found initrd image: /boot/initramfs-0-rescue-13fa607805964427bb4a2297f3619e6e.img
done

■ 然后重启系统生效

reboot

■ 在 Red Hat 7.3 测试内核升级

[root@node5 ~]# cat /etc/*release
Red Hat Enterprise Linux Server release 7.3 (Maipo)

【升级前】

[root@node5 ~]# uname -a
Linux node5 3.10.0-514.el7.x86_64 #1 SMP Wed Oct 19 11:24:13 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@node5 ~]# cat /proc/version
Linux version 3.10.0-514.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Wed Oct 19 11:24:13 EDT 2016
[root@node5 ~]# uname -rs
Linux 3.10.0-514.el7.x86_64

【升级后】

[root@node5 ~]# uname -a
Linux node5 5.4.214-1.el7.elrepo.x86_64 #1 SMP Sat Sep 17 11:09:50 EDT 2022 x86_64 x86_64 x86_64 GNU/Linux
[root@node5 ~]# cat /proc/version
Linux version 5.4.214-1.el7.elrepo.x86_64 (mockbuild@Build64R7) (gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)) #1 SMP Sat Sep 17 11:09:50 EDT 2022
[root@node5 ~]# uname -rs
Linux 5.4.214-1.el7.elrepo.x86_64

■ 在 CentOS 7.6 测试内核升级

[root@node3:0 ~]# cat /etc/*release
CentOS Linux release 7.6.1810 (Core)

【升级前】

[root@node3:0 ~]# uname -a
Linux node3 3.10.0-1160.15.2.el7.x86_64 #1 SMP Wed Feb 3 15:06:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
[root@node3:0 ~]# cat /proc/version
Linux version 3.10.0-1160.15.2.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Wed Feb 3 15:06:38 UTC 2021
[root@node3:0 ~]# uname -rs
Linux 3.10.0-1160.15.2.el7.x86_64

【升级后】

[root@node3:0 ~]# uname -a
Linux node3 5.4.214-1.el7.elrepo.x86_64 #1 SMP Sat Sep 17 11:09:50 EDT 2022 x86_64 x86_64 x86_64 GNU/Linux
[root@node3:0 ~]# cat /proc/version
Linux version 5.4.214-1.el7.elrepo.x86_64 (mockbuild@Build64R7) (gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)) #1 SMP Sat Sep 17 11:09:50 EDT 2022
[root@node3:0 ~]# uname -rs
Linux 5.4.214-1.el7.elrepo.x86_64

标签:x86,linux,离线,64,内核,Linux,root,el7,亲测
From: https://www.cnblogs.com/likingzi/p/16744415.html

相关文章

  • Java 模拟Terminal连接 Linux Console 源代码
    代码和效果如下,已经转换java文件为exe文件,注意要在Pom文件里面添加依赖。  packagecom.javassh3.javassh3;/*-*-mode:java;c-basic-offset:2;indent-tabs-mode:n......
  • linux切割日志文件的shell脚本
    #!/bin/bash#获取前一天的日期suffix=`date-d"-1day""+%Y%m%d"`#split命令用于切割文件#-bSIZE:SIZEisanintegerandoptionalunit(example:10Mis10*102......
  • Linux下的shell工作原理是什么?
    Linux系统提供给用户的最重要的系统程序是Shell命令语言​​解释程序​​​。它不属于内核部分,而是在核心之外,以用户态方式运行。其基本功能是解释并执行用户打入的各种命......
  • linux初始化MySQL数据库
    1.停止MySQL  2.删除数据库中所有的文件及日志[root@localhost~]#rm-rf/var/lib/mysql/*#删除mysql目录下所以文件[root@localhost~]#rm-rf/var/log/mysqld.......
  • LINUX常用命令备忘
    问1:linux在虚拟机下咋么从图形模式切换到命令行模式的啊答:运行init3NOTE:在windows虚拟机模式下,Ctrl+Alt+F1~F7,是失效的。但如下却屡试不爽(特别感谢乐乐):终端模式-->命令行......
  • linux可控的复杂度原因探讨
    一、影响复杂度控制的因素总结1)架构。要拥有绝对良好的架构。否则操作系统这种“高楼大厦”是不可能建成的,建到一半就跨了,而且不坚固。2)模块性:保持清晰,保持简洁。(keepingi......
  • linux socket实现网络聊天室(一):服务器和客户端对话
    1.服务器端#include<sys/types.h>#include<sys/socket.h>#include<stdio.h>#include<stdlib.h>#include<errno.h>#include<string.h>#include<unistd.h>#include<ne......
  • linux C 开发中重要的数据结构——结构体
    在linux的驱动开发中,最常用的,也最重要的数据结构是结构体,它也最容易使人混淆。要掌握结构体,首先要弄明白运算符的优先级:在所有运算符中,下面4个运算......
  • 将程序添加为Linux系统服务
     将程序注册为系统服务后,可通过systemctl和service系统命令启动,查看,停止程序,并可以将程序设置为开机自启动等等。将程序注册为系统服务,需要编辑xxx.service文件,......
  • linux 常用命令整理
    1.创建多级目录mkdir-pfolder1/folder2/folder3folder1>folder2>folder32.清理緩存echo1>/proc/sys/vm/drop_c......