在操作软件时,很多时候会遇见内核版本过低的情况,本文主要学习升级内核版本。
升级内核操作需谨慎。
核心命令
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
yum install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
yum --disablerepo="*" --enablerepo="elrepo-kernel" install kernel-ml
grub2-set-default 0
详细步骤请往里走。
uname -r
4.18.0-193.14.2.el8_2.x86_64
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
yum install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
[root@iZhp33j6fklnmhbf0lz2obZ yum.repos.d]# yum install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
/usr/lib/python3.6/site-packages/OpenSSL/crypto.py:12: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.
from cryptography import x509
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
CentOS Linux 8 - AppStream
42 B/s | 38 B 00:00
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
[root@iZhp33j6fklnmhbf0lz2obZ yum.repos.d]# sudo sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
[root@iZhp33j6fklnmhbf0lz2obZ yum.repos.d]# sudo sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
[root@iZhp33j6fklnmhbf0lz2obZ yum.repos.d]# yum install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
/usr/lib/python3.6/site-packages/OpenSSL/crypto.py:12: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.
from cryptography import x509
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
CentOS Linux 8 - AppStream ...
Installed:
elrepo-release-8.3-1.el8.elrepo.noarch
Complete!
出现报错:
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
CentOS团队从官方镜像中移除CentOS 8的所有包,但软件包仍在官方镜像上保留一段时间。现在被转移到https://vault.centos.org。如需继续运行旧CentOS 8,可以在/etc/yum.repos中更新repos.d,使用vault.centos.org代替mirror.centos.org
sudo sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sudo sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos
启用 ELRepo 源仓库
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
安装
在 ELRepo 中有两个内核选项,一个是 kernel-lt(长期支持版本),一个是 kernel-ml(主线最新版本),采用长期支持版本(kernel-lt)更稳定。
yum --enablerepo=elrepo-kernel install kernel-ml
[root@iZhp33j6fklnmhbf0lz2obZ yum.repos.d]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
/usr/lib/python3.6/site-packages/OpenSSL/crypto.py:12: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.
from cryptography import x509
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
ELRepo.org Community Enterprise Linux Kernel Repository - el8
441 kB/s | 2.1 MB 00:04
Last metadata expiration check: 0:00:01 ago on Thu 18 Aug 2022 05:56:16 PM CST.
Available Packages
bpftool.x86_64 5.19.2-1.el8.elrepo ...
perf.x86_64 5.19.2-1.el8.elrepo
elrepo-kernel
python3-perf.x86_64 5.19.2-1.el8.elrepo
elrepo-kernel
[root@iZhp33j6fklnmhbf0lz2obZ yum.repos.d]# yum --disablerepo="*" --enablerepo="elrepo-kernel" install kernel-ml
/usr/lib/python3.6/site-packages/OpenSSL/crypto.py:12: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography and will be removed in a future release.
from cryptography import x509
Version Repository
...
Installed:
kernel-ml-5.19.2-1.el8.elrepo.x86_64 kernel-ml-core-5.19.2-1.el8.elrepo.x86_64 kernel-ml-modules-5.19.2-1.el8.elrepo.x86_64
Complete!
查看当前默认启动内核
grubby --default-kernel
[root@iZhp33j6fklnmhbf0lz2obZ yum.repos.d]# grubby --default-kernel
/boot/vmlinuz-5.19.2-1.el8.elrepo.x86_64
0 表示最新安装的内核,设置为 0 表示以新版本内核启动:
grub2-set-default 0
或指定内核启动
grubby --set-default /boot/vmlinuz-5.19.2-1.el8.elrepo.x86_64
[root@iZhp33j6fklnmhbf0lz2obZ yum.repos.d]# uname -r
5.19.2-1.el8.elrepo.x86_64
点赞 收藏 关注