查看当前内核版本
使用uname命令查看内核版本,其中-a选项输出信息更为详细。
# uname -a
Linux ibetterlife 5.14.0-162.18.1.el9_1.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Mar 1 22:02:24 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
# uname -r
5.14.0-162.18.1.el9_1.x86_64
启用 ELRepo
ELRepo是企业Linux软件包的RPM存储库。ELRepo支持Red Hat Enterprise Linux (RHEL) 及其衍生产品,如Scientific Linux、CentOS Linux、Alma Linux 和 Rocky Linux。ELRepo项目专注于与硬件相关的软件包,以增强您对Enterprise Linux 的体验。这包括文件系统驱动程序、图形驱动程序、网络驱动程序、声音驱动程序、网络摄像头和视频驱动程序。
从CentOS/AlmaLinux/RockLinux 8开始,ELRepo已经加入到官方软件仓库中,名称为 “elrepo-release”。
启用ELRepo只需要执行命令:
dnf -y install elrepo-release
安装ELRepo公钥
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
ELRepo rpm包在线安装方法
# Import the public key:
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# To install ELRepo for RHEL-**9** or CentOS-**9**:
yum install https://www.elrepo.org/elrepo-release-9.el9.elrepo.noarch.rpm
# To install ELRepo for RHEL-**8** or CentOS-**8**:
yum install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
# To install ELRepo for RHEL-**7**, SL-**7** or CentOS-**7**:
yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
# To make use of our mirror system, **please also install yum-plugin-fastestmirror**.
升级内核
查询ELRepo中的kernel版本
# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
Last metadata expiration check: 0:21:04 ago on Wed 22 Mar 2023 04:10:15 PM CST.
Available Packages
bpftool.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-core.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-devel.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-devel-matched.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-doc.noarch 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-headers.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-modules.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-modules-extra.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-tools.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
perf.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
python3-perf.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available --showduplicates
Last metadata expiration check: 0:44:46 ago on Wed 22 Mar 2023 04:10:15 PM CST.
Available Packages
bpftool.x86_64 6.2.6-1.el9.elrepo elrepo-kernel
bpftool.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
elrepo-release.noarch 9.1-1.el9.elrepo elrepo-kernel
kernel-ml.x86_64 6.2.6-1.el9.elrepo elrepo-kernel
kernel-ml.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-core.x86_64 6.2.6-1.el9.elrepo elrepo-kernel
kernel-ml-core.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-devel.x86_64 6.2.6-1.el9.elrepo elrepo-kernel
kernel-ml-devel.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-devel-matched.x86_64 6.2.6-1.el9.elrepo elrepo-kernel
kernel-ml-devel-matched.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-doc.noarch 6.2.6-1.el9.elrepo elrepo-kernel
kernel-ml-doc.noarch 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-headers.x86_64 6.2.6-1.el9.elrepo elrepo-kernel
kernel-ml-headers.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-modules.x86_64 6.2.6-1.el9.elrepo elrepo-kernel
kernel-ml-modules.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-modules-extra.x86_64 6.2.6-1.el9.elrepo elrepo-kernel
kernel-ml-modules-extra.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-tools.x86_64 6.2.6-1.el9.elrepo elrepo-kernel
kernel-ml-tools.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 6.2.6-1.el9.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 6.2.6-1.el9.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
perf.x86_64 6.2.6-1.el9.elrepo elrepo-kernel
perf.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
python3-perf.x86_64 6.2.6-1.el9.elrepo elrepo-kernel
python3-perf.x86_64 6.2.7-1.el9.elrepo elrepo-kernel
术语解释
kernel-ml
kernel-ml中的ml是英文 “mainline stable” 的缩写,elrepo-kernel中列出来的是最新的稳定主线版本。
kernel-lt
kernel-lt中的lt是英文 “long term support” 的缩写,elrepo-kernel 中列出来的长期支持版本。
安装kernel
安装新内核(kernel-core、kernel-modules 与 kernel 依赖自动更新)
# yum --disablerepo=\* --enablerepo=elrepo-kernel install -y kernel-ml.x86_64
安装新内核相关软件(--skip-broken必须)
# yum --disablerepo=\* --enablerepo=elrepo-kernel install -y kernel-ml-devel kernel-ml-tools kernel-ml-tools-libs kernel-ml-tools-libs-devel kernel-ml-headers --skip-broken
确认默认启动内核(般更新的内核为默认启动内核)
# grubby --default-kernel
/boot/vmlinuz-6.2.7-1.el9.elrepo.x86_64
如果不是的话,先看查看系统安装的全部内核
# grubby --default-kernel
/boot/vmlinuz-6.2.7-1.el9.elrepo.x86_64
[root@iZuf6g4xzntqr7ucc5swmkZ ~]# grubby --info=ALL
index=0
kernel="/boot/vmlinuz-6.2.7-1.el9.elrepo.x86_64"
args="ro rhgb quiet net.ifnames=0 console=tty0 console=ttyS0,115200n8 nvme_core.io_timeout=4294967295 nvme_core.admin_timeout=4294967295 crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M $tuned_params"
root="UUID=8537de8b-6254-450c-9946-5ff5ad4af6dc"
initrd="/boot/initramfs-6.2.7-1.el9.elrepo.x86_64.img $tuned_initrd"
title="Rocky Linux (6.2.7-1.el9.elrepo.x86_64) 9.1 (Blue Onyx)"
id="20220630095603711861013686113992-6.2.7-1.el9.elrepo.x86_64"
index=1
kernel="/boot/vmlinuz-5.14.0-162.18.1.el9_1.x86_64"
args="ro rhgb quiet net.ifnames=0 console=tty0 console=ttyS0,115200n8 nvme_core.io_timeout=4294967295 nvme_core.admin_timeout=4294967295 $tuned_params crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M"
root="UUID=8537de8b-6254-450c-9946-5ff5ad4af6dc"
initrd="/boot/initramfs-5.14.0-162.18.1.el9_1.x86_64.img $tuned_initrd"
title="Rocky Linux (5.14.0-162.18.1.el9_1.x86_64) 9.1 (Blue Onyx)"
id="20220630095603711861013686113992-5.14.0-162.18.1.el9_1.x86_64"
index=2
kernel="/boot/vmlinuz-0-rescue-20220630095603711861013686113992"
args="ro rhgb quiet net.ifnames=0 console=tty0 console=ttyS0,115200n8 nvme_core.io_timeout=4294967295 nvme_core.admin_timeout=4294967295 crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M"
root="UUID=8537de8b-6254-450c-9946-5ff5ad4af6dc"
initrd="/boot/initramfs-0-rescue-20220630095603711861013686113992.img"
title="Rocky Linux (0-rescue-20220630095603711861013686113992) 8.6 (Green Obsidian)"
id="20220630095603711861013686113992-0-rescue"
设置新的默认启动内核
# grubby --set-default=/boot/vmlinuz-6.2.7-1.el9.elrepo.x86_64
或者
# grubby --set-default-index=0
重启之后,再次查看内核版本
# uname -a
Linux iZuf6g4xzntqr7ucc5swmkZ 5.14.0-162.18.1.el9_1.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Mar 1 22:02:24 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
# uname -r
6.2.7-1.el9.elrepo.x86_64
删除旧内核 ##(可选的)
# rpm -e --nodeps `rpm -qa|grep -i kernel|grep 5.14`
再次查看当前的内核,检查是否删除成功。
# rpm -qa | grep kernel
kernel-srpm-macros-1.0-11.el9.noarch
kernel-ml-core-6.2.7-1.el9.elrepo.x86_64
kernel-ml-modules-6.2.7-1.el9.elrepo.x86_64
kernel-ml-6.2.7-1.el9.elrepo.x86_64
Comments | NOTHING