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 内核常规问题已解决

相关推荐
IP管家几秒前
物联网设备远程管理:基于代理IP的安全固件更新通道方案
服务器·网络·物联网·网络协议·tcp/ip·安全·ip
搬码临时工7 分钟前
远程连接电脑的方法?异地远程桌面连接和三方软件实现
运维·服务器·网络·物联网·电脑·远程工作
窦再兴23 分钟前
来一个复古的技术FTP
linux·运维·服务器
梦在深巷、28 分钟前
nginx配置之负载均衡
运维·nginx·负载均衡
陌路物是人非32 分钟前
uniapp取消浏览自动填充
java·服务器·uni-app
xiaobin8899941 分钟前
【2025最新版】VMware虚拟机下载安装教程 保姆级图文详解(附安装包+常用镜像Linux,win11,ubuntu,centos)
linux·其他·ubuntu·centos
小黑_深呼吸1 小时前
Prometheus实战教程:k8s平台-Mysql监控案例
运维·学习·kubernetes·prometheus
ALex_zry1 小时前
Ubuntu 20.04 C++开发环境搭建指南(2025版)
linux·c++·ubuntu
疯狂的挖掘机2 小时前
记一次从windows连接远程Linux系统来控制设备采集数据方法
linux·运维·windows
斯密码赛我是美女2 小时前
ssti刷刷刷
java·服务器·前端