一、下载内核rpm包
[root@localip src]# wget http://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/x86_64/RPMS/kernel-ml-5.19.0-1.el7.elrepo.x86_64.rpm
[root@localip src]# wget http://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/x86_64/RPMS/kernel-ml-devel-5.19.0-1.el7.elrepo.x86_64.rpm
二、安装rpm包
[root@localip src]# rpm -ivh kernel-ml-5.19.0-1.el7.elrepo.x86_64.rpm warning: kernel-ml-5.19.0-1.el7.elrepo.x86_64.rpm: Header V4 DSA/SHA256 Signature, key ID baadae52: NOKEY Preparing... ################################# [100%] Updating / installing... 1:kernel-ml-5.19.0-1.el7.elrepo ################################# [100%] [root@localip src]# rpm -ivh kernel-ml-devel-5.19.0-1.el7.elrepo.x86_64.rpm warning: kernel-ml-devel-5.19.0-1.el7.elrepo.x86_64.rpm: Header V4 DSA/SHA256 Signature, key ID baadae52: NOKEY Preparing... ################################# [100%] Updating / installing... 1:kernel-ml-devel-5.19.0-1.el7.elre################################# [100%]
三、修改GRUB中默认的内核版本
1、内核升级完毕后,目前内核还是默认的版本,如果此时直接执行reboot
命令,重启后使用的内核版本还是默认的3.10
,不会使用新的5.5.8
,首先,我们可以通过命令查看默认启动顺序
[root@localip src]# awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg 0 : CentOS Linux (5.19.0-1.el7.elrepo.x86_64) 7 (Core) 1 : CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core) 2 : CentOS Linux (0-rescue-8804b70dc1c5481d8f22c9c22d11cc93) 7 (Core)
2、由上面可以看出新内核(5.5.8)目前位置在0,原来的内核(3.10.0)目前位置在1,所以如果想生效最新的内核,还需要我们修改内核的启动顺序为0
[root@localip src]# grub2-set-default 0
3、运行grub2-mkconfig
命令来重新创建内核配置
[root@localip src]# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-5.19.0-1.el7.elrepo.x86_64 Found initrd image: /boot/initramfs-5.19.0-1.el7.elrepo.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-1160.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-1160.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-8804b70dc1c5481d8f22c9c22d11cc93 Found initrd image: /boot/initramfs-0-rescue-8804b70dc1c5481d8f22c9c22d11cc93.img done [root@localip src]#
四、重启并查看内核
[root@localip ~]# uname -a Linux localip 5.19.0-1.el7.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jul 31 19:04:17 EDT 2022 x86_64 x86_64 x86_64 GNU/Linux [root@localip ~]# cat /proc/version Linux version 5.19.0-1.el7.elrepo.x86_64 (mockbuild@Build64R7) (gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2), GNU ld version 2.32-16.el7) #1 SMP PREEMPT_DYNAMIC Sun Jul 31 19:04:17 EDT 2022