• 【Linux】最新CentOS8内核升级


    前言

    在操作软件时,很多时候会遇见内核版本过低的情况,本文主要学习升级内核版本。

    升级内核操作需谨慎。

    核心命令

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5

    详细步骤请往里走。

    1、查看当前内核版本

    uname -r
    
    • 1
    4.18.0-193.14.2.el8_2.x86_64
    
    • 1

    2、导入ELRepo仓库的公共密钥:

    rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
    
    • 1

    3、安装ELRepo仓库的yum源

    yum install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
    
    • 1
    [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!
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    出现报错:

    Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
    
    • 1

    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
    
    • 1
    • 2

    4、安装最新版内核

    启用 ELRepo 源仓库

    yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
    
    • 1

    安装
    在 ELRepo 中有两个内核选项,一个是 kernel-lt(长期支持版本),一个是 kernel-ml(主线最新版本),采用长期支持版本(kernel-lt)更稳定。

    yum --enablerepo=elrepo-kernel install kernel-ml
    
    • 1
    [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!
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    5、设置以新的内核启动

    查看当前默认启动内核

    grubby --default-kernel
    
    • 1
    [root@iZhp33j6fklnmhbf0lz2obZ yum.repos.d]# grubby --default-kernel
    /boot/vmlinuz-5.19.2-1.el8.elrepo.x86_64
    
    • 1
    • 2

    0 表示最新安装的内核,设置为 0 表示以新版本内核启动:

    grub2-set-default 0
    
    • 1

    或指定内核启动

    grubby --set-default /boot/vmlinuz-5.19.2-1.el8.elrepo.x86_64
    
    • 1

    6、重启验证新内核

    [root@iZhp33j6fklnmhbf0lz2obZ yum.repos.d]# uname -r
    5.19.2-1.el8.elrepo.x86_64
    
    • 1
    • 2

    在这里插入图片描述
    点赞 收藏 关注

  • 相关阅读:
    CVPR2020-视觉不平衡立体匹配
    rand()函数产生随机数详解
    Axios请求封装
    kafka单机部署
    【语音识别】基于LMS算法消除嘈杂的鸟类语音信号中的噪声后识别其对应的鸟类物种(Matlab代码实现)
    mysql的DDL语言和DML语言
    Java重修笔记 第三十天 异常
    【利用冒泡排序的思想模拟实现qsort函数】
    windows terminal鼠标右键打开
    高并发下秒杀商品,你必须知道的9个细节
  • 原文地址:https://blog.csdn.net/qq_35764295/article/details/126411421