Linux 默认内核版本更改

随笔记录

目录

[1. 背景介绍](#1. 背景介绍)

[2. 解决方法](#2. 解决方法)

[2.1 查看所有可用版本](#2.1 查看所有可用版本)

[2.2 安装指定版本内核](#2.2 安装指定版本内核)

[2.3 检查当前内核列表](#2.3 检查当前内核列表)

[2.4 检查当前默认内核](#2.4 检查当前默认内核)

[2.5 设置新的默认内核](#2.5 设置新的默认内核)

[2.6 确认内核是否成功加载](#2.6 确认内核是否成功加载)

[2.7 重启](#2.7 重启)

[2.8 删除其他版本内核](#2.8 删除其他版本内核)


1. 背景介绍

linux 一般安装多个内核版本,但会设置一个开机启动默认内核版本。

如果需要升级内核版本,且找不到需要升级的内核版本时,可通过更改默认内核版本解决。

2. 解决方法

2.1 查看所有可用版本

# 查看所有可用版本

yum list kernel --showduplicates


[root@localhost ~]#
[root@localhost ~]# yum list kernel --showduplicates
Repository base is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Last metadata expiration check: 1:16:35 ago on Sun 29 Sep 2024 08:39:22 AM CST.
Installed Packages
kernel.x86_64                                                    4.18.0-373.el8                                                           @baseos
kernel.x86_64                                                    4.18.0-408.el8                                                           @anaconda
kernel.x86_64                                                    4.18.0-553.5.1.el8                                                       @baseos
Available Packages
kernel.x86_64                                                    4.18.0-348.el8                                                           base
kernel.x86_64                                                    4.18.0-348.2.1.el8_5                                                     base
kernel.x86_64                                                    4.18.0-348.7.1.el8_5                                                     base
kernel.x86_64                                                    4.18.0-552.el8                                                           baseos
kernel.x86_64                                                    4.18.0-552.1.1.el8                                                       baseos
kernel.x86_64                                                    4.18.0-552.3.1.el8                                                       baseos
kernel.x86_64                                                    4.18.0-553.5.1.el8                                                       baseos
kernel.x86_64                                                    4.18.0-553.6.1.el8                                                       baseos
[root@localhost ~]#
[root@localhost ~]#

2.2 安装指定版本内核

可以下载安装指定内核版本,也可以直接使用现有内核版本设置为默认内核

# 安装指定版本内核
yum install kernel kernel-4.18.0-373.el8.x86_64 -y

2.3 检查当前内核列表

# 检查当前内核列表

grubby --info=ALL | grep ^kernel

[root@localhost ~]#
[root@localhost ~]# grubby --info=ALL | grep ^kernel

kernel="/boot/vmlinuz-4.18.0-553.5.1.el8.x86_64"
kernel="/boot/vmlinuz-4.18.0-408.el8.x86_64"
kernel="/boot/vmlinuz-4.18.0-373.el8.x86_64"
kernel="/boot/vmlinuz-0-rescue-dcf1251e2ffb44dfa5f6567c29d0c6d7"
[root@localhost ~]#

2.4 检查当前默认内核

# 检查当前默认内核
grubby --default-kernel

2.5 设置新的默认内核

# 设置新的默认内核
grubby --set-default "/boot/vmlinuz-4.18.0-373.el8.x86_64"

2.6 确认内核是否成功加载

# 确认内核是否成功加载

grubby --default-kernel


[root@localhost ~]#
[root@localhost ~]# grubby --default-kernel
/boot/vmlinuz-4.18.0-553.5.1.el8.x86_64
[root@localhost ~]#
[root@localhost ~]#

2.7 重启

reboot

2.8 删除其他版本内核

# 删除其他版本内核


yum remove kernel kernel-4.18.0-407.el8.x86_64 -y

到此Linux 内核常规问题已解决

相关推荐
渲染101专业云渲染1 分钟前
川翔云电脑优势总结
服务器·3d·电脑·blender·maya
chian-ocean19 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=21 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
橘子味的茶二30 分钟前
高级系统架构师--第十章:计算机网络
服务器·计算机网络·系统架构
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
紫菜(Nori)1 小时前
短连接服务器压测-wrk
服务器·压力测试
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
陆沙1 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
北京耐用通信1 小时前
航空装配自动化神器Ethercat转profient网关搭配机器人精准控制
运维·机器人·自动化