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. 安装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!
  3. 查看当前系统中可用的内核版本,如下

    <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)
  4. 更改启动时默认加载的内核

    <root@iZj6c8bzfr4cvcyc42e6kqZ ~># grub2-set-default 0
    <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
原文地址:https://www.cnblogs.com/apink/p/15172320.html