CentOS内核升级

  1. 安装elrepo源,如下
    <root@iZj6c8bzfr4cvcyc42e6kqZ ~># rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
    <root@iZj6c8bzfr4cvcyc42e6kqZ ~># rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
    Retrieving https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:elrepo-release-7.0-3.el7.elrepo  ################################# [100%]
  2. 查看elrepo的可用的内核
    <root@HK-K8S-CP ~># yum list available --disablerepo='*' --enablerepo=elrepo-kernel
    Loaded plugins: fastestmirror
    Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
    Loading mirror speeds from cached hostfile
     * elrepo-kernel: mirrors.tuna.tsinghua.edu.cn
    Available Packages
    elrepo-release.noarch                                                                                    7.0-5.el7.elrepo                                                                            elrepo-kernel
    kernel-lt.x86_64                                                                                         5.4.100-1.el7.elrepo                                                                        elrepo-kernel
    kernel-lt-devel.x86_64                                                                                   5.4.100-1.el7.elrepo                                                                        elrepo-kernel
    kernel-lt-doc.noarch                                                                                     5.4.100-1.el7.elrepo                                                                        elrepo-kernel
    kernel-lt-headers.x86_64                                                                                 5.4.100-1.el7.elrepo                                                                        elrepo-kernel
    kernel-lt-tools.x86_64                                                                                   5.4.100-1.el7.elrepo                                                                        elrepo-kernel
    kernel-lt-tools-libs.x86_64                                                                              5.4.100-1.el7.elrepo                                                                        elrepo-kernel
    kernel-lt-tools-libs-devel.x86_64                                                                        5.4.100-1.el7.elrepo                                                                        elrepo-kernel
    kernel-ml-devel.x86_64                                                                                   5.11.1-1.el7.elrepo                                                                         elrepo-kernel
    kernel-ml-doc.noarch                                                                                     5.11.1-1.el7.elrepo                                                                         elrepo-kernel
    kernel-ml-headers.x86_64                                                                                 5.11.1-1.el7.elrepo                                                                         elrepo-kernel
    kernel-ml-tools.x86_64                                                                                   5.11.1-1.el7.elrepo                                                                         elrepo-kernel
    kernel-ml-tools-libs.x86_64                                                                              5.11.1-1.el7.elrepo                                                                         elrepo-kernel
    kernel-ml-tools-libs-devel.x86_64                                                                        5.11.1-1.el7.elrepo                                                                         elrepo-kernel
    perf.x86_64                                                                                              5.11.1-1.el7.elrepo                                                                         elrepo-kernel
    python-perf.x86_64                                                                                       5.11.1-1.el7.elrepo                                                                         elrepo-kernel
  3. 安装stable版本内核,如下
    <root@iZj6c8bzfr4cvcyc42e6kqZ ~># yum --enablerepo=elrepo-kernel install kernel-ml
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * elrepo: hkg.mirror.rackspace.com
     * elrepo-kernel: hkg.mirror.rackspace.com
    elrepo                                                                                                                                                                                     | 3.0 kB  00:00:00    
    elrepo-kernel                                                                                                                                                                              | 3.0 kB  00:00:00    
    (1/2): elrepo/primary_db                                                                                                                                                                   | 341 kB  00:00:00    
    (2/2): elrepo-kernel/primary_db                                                                                                                                                            | 2.0 MB  00:00:00    
    Resolving Dependencies
    --> Running transaction check
    ---> Package kernel-ml.x86_64 0:5.11.1-1.el7.elrepo will be installed
    --> Finished Dependency Resolution
     
    Dependencies Resolved
     
    ==================================================================================================================================================================================================================
     Package                                         Arch                                         Version                                                   Repository                                           Size
    ==================================================================================================================================================================================================================
    Installing:
     kernel-ml                                       x86_64                                       5.11.1-1.el7.elrepo                                       elrepo-kernel                                        53 M
     
    Transaction Summary
    ==================================================================================================================================================================================================================
    Install  1 Package
     
    Total download size: 53 M
    Installed size: 240 M
    Is this ok [y/d/N]: y
    Downloading packages:
    kernel-ml-5.11.1-1.el7.elrepo.x86_64.rpm                                                                                                                                                   |  53 MB  00:00:01    
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
    Warning: RPMDB altered outside of yum.
      Installing : kernel-ml-5.11.1-1.el7.elrepo.x86_64                                                                                                                                                           1/1
      Verifying  : kernel-ml-5.11.1-1.el7.elrepo.x86_64                                                                                                                                                           1/1
     
    Installed:
      kernel-ml.x86_64 0:5.11.1-1.el7.elrepo                                                                                                                                                                         
     
    Complete!
  4. 查看当前系统中可用的内核版本,如下

    <root@iZj6c8bzfr4cvcyc42e6kqZ ~># awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
    0 : CentOS Linux (5.11.1-1.el7.elrepo.x86_64) 7 (Core)
    1 : CentOS Linux (3.10.0-1062.9.1.el7.x86_64) 7 (Core)
    2 : CentOS Linux (3.10.0-1062.el7.x86_64) 7 (Core)
    3 : CentOS Linux (0-rescue-20191225111607875619293640639763) 7 (Core)
  5. 更改启动时默认加载的内核

    <root@iZj6c8bzfr4cvcyc42e6kqZ ~># grub2-set-default 'CentOS Linux (5.11.1-1.el7.elrepo.x86_64) 7 (Core)'
    <root@iZj6c8bzfr4cvcyc42e6kqZ ~># grub2-mkconfig -o /boot/grub2/grub.cfg
    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-5.11.1-1.el7.elrepo.x86_64
    Found initrd image: /boot/initramfs-5.11.1-1.el7.elrepo.x86_64.img
    Found linux image: /boot/vmlinuz-3.10.0-1062.9.1.el7.x86_64
    Found initrd image: /boot/initramfs-3.10.0-1062.9.1.el7.x86_64.img
    Found linux image: /boot/vmlinuz-3.10.0-1062.el7.x86_64
    Found initrd image: /boot/initramfs-3.10.0-1062.el7.x86_64.img
    Found linux image: /boot/vmlinuz-0-rescue-20191225111607875619293640639763
    Found initrd image: /boot/initramfs-0-rescue-20191225111607875619293640639763.img
    done
  6. 查看当前默认启动内核版本

    grub2-editenv list
posted @ 2021-08-22 15:09  MacoPlus  阅读(78)  评论(0编辑  收藏  举报