centos7 升级最新版内核

本文详细介绍了如何在Linux系统中检查当前内核版本,设置内核源,安装并更新到最新内核,以及如何设置默认启动内核和验证设置是否成功。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

查看内核

uname -r

设置内核源

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

查看可用系统内核包

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

以下为可用的内核包

kernel-lt.x86_64                                                                                         4.4.192-1.el7.elrepo                                                                        elrepo-kernel
kernel-lt-devel.x86_64                                                                                   4.4.192-1.el7.elrepo                                                                        elrepo-kernel
kernel-lt-doc.noarch                                                                                     4.4.192-1.el7.elrepo                                                                        elrepo-kernel
kernel-lt-headers.x86_64                                                                                 4.4.192-1.el7.elrepo                                                                        elrepo-kernel
kernel-lt-tools.x86_64                                                                                   4.4.192-1.el7.elrepo                                                                        elrepo-kernel
kernel-lt-tools-libs.x86_64                                                                              4.4.192-1.el7.elrepo                                                                        elrepo-kernel
kernel-lt-tools-libs-devel.x86_64                                                                        4.4.192-1.el7.elrepo                                                                        elrepo-kernel
kernel-ml.x86_64                                                                                         5.2.14-1.el7.elrepo                                                                         elrepo-kernel
kernel-ml-devel.x86_64                                                                                   5.2.14-1.el7.elrepo                                                                         elrepo-kernel
kernel-ml-doc.noarch                                                                                     5.2.14-1.el7.elrepo                                                                         elrepo-kernel
kernel-ml-headers.x86_64                                                                                 5.2.14-1.el7.elrepo                                                                         elrepo-kernel
kernel-ml-tools.x86_64                                                                                   5.2.14-1.el7.elrepo                                                                         elrepo-kernel
kernel-ml-tools-libs.x86_64                                                                              5.2.14-1.el7.elrepo                                                                         elrepo-kernel
kernel-ml-tools-libs-devel.x86_64                                                                        5.2.14-1.el7.elrepo                                                                         elrepo-kernel
perf.x86_64                                                                                              5.2.14-1.el7.elrepo                                                                         elrepo-kernel
python-perf.x86_64                                                                                       5.2.14-1.el7.elrepo                                                                         elrepo-kernel

安装最新内核

yum --enablerepo=elrepo-kernel install kernel-ml

设置内核

更新内核

grub2-mkconfig -o /boot/grub2/grub.cfg

输出

Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.2.14-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-5.2.14-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-957.21.3.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.21.3.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-957.5.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.5.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-4284cfe27c5b48c38adde30f33b4bb60
Found initrd image: /boot/initramfs-0-rescue-4284cfe27c5b48c38adde30f33b4bb60.img
done

查看系统内核

cat /boot/grub2/grub.cfg |grep menuentry

输出

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
  menuentry_id_option=""
export menuentry_id_option
menuentry 'CentOS Linux (5.2.14-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-5.2.14-1.el7.elrepo.x86_64-advanced-4c2c090d-4228-49fc-9cbe-3920b3bf287c' {
menuentry 'CentOS Linux (3.10.0-957.21.3.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.21.3.el7.x86_64-advanced-4c2c090d-4228-49fc-9cbe-3920b3bf287c' {
menuentry 'CentOS Linux (3.10.0-957.5.1.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.5.1.el7.x86_64-advanced-4c2c090d-4228-49fc-9cbe-3920b3bf287c' {
menuentry 'CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.el7.x86_64-advanced-4c2c090d-4228-49fc-9cbe-3920b3bf287c' {
menuentry 'CentOS Linux (0-rescue-4284cfe27c5b48c38adde30f33b4bb60) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-4284cfe27c5b48c38adde30f33b4bb60-advanced-4c2c090d-4228-49fc-9cbe-3920b3bf287c' {

设置内核

设置默认内核(注意上面的输出)

grub2-set-default "CentOS Linux (5.2.14-1.el7.elrepo.x86_64) 7 (Core)"

验证

grub2-editenv list

输出(下面说明设置成功)

saved_entry=CentOS Linux (5.2.14-1.el7.elrepo.x86_64) 7 (Core)

重启电脑

reboot

查看内核

uname -r

输出

5.2.14-1.el7.elrepo.x86_64

OK

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值