当前位置:   article > 正文

centos7.4升级内核3.x到5.x,使用yum安装的方式_cent7升级linux内核版本3还是5

cent7升级linux内核版本3还是5

1、centos版本

cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core)
  • 1
  • 2

2、导入elrepo的key,然后安装elrepo的yum源

rpm -import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
  • 1
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
  • 1
获取http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
获取http://elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm
准备中...                          ################################# [100%]
正在升级/安装...
   1:elrepo-release-7.0-4.el7.elrepo  ################################# [100%]
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

3、列出可升级的内核

yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
  • 1
已加载插件:fastestmirror
elrepo-kernel                                                 | 2.9 kB  00:00:00     
elrepo-kernel/primary_db                                      | 1.9 MB  00:00:09     
Loading mirror speeds from cached hostfile
 * elrepo-kernel: mirrors.tuna.tsinghua.edu.cn
可安装的软件包
elrepo-release.noarch                     7.0-5.el7.elrepo              elrepo-kernel
kernel-lt.x86_64                          4.4.232-1.el7.elrepo          elrepo-kernel
kernel-lt-devel.x86_64                    4.4.232-1.el7.elrepo          elrepo-kernel
kernel-lt-doc.noarch                      4.4.232-1.el7.elrepo          elrepo-kernel
kernel-lt-headers.x86_64                  4.4.232-1.el7.elrepo          elrepo-kernel
kernel-lt-tools.x86_64                    4.4.232-1.el7.elrepo          elrepo-kernel
kernel-lt-tools-libs.x86_64               4.4.232-1.el7.elrepo          elrepo-kernel
kernel-lt-tools-libs-devel.x86_64         4.4.232-1.el7.elrepo          elrepo-kernel
kernel-ml.x86_64                          5.8.0-1.el7.elrepo            elrepo-kernel
kernel-ml-devel.x86_64                    5.8.0-1.el7.elrepo            elrepo-kernel
kernel-ml-doc.noarch                      5.8.0-1.el7.elrepo            elrepo-kernel
kernel-ml-headers.x86_64                  5.8.0-1.el7.elrepo            elrepo-kernel
kernel-ml-tools.x86_64                    5.8.0-1.el7.elrepo            elrepo-kernel
kernel-ml-tools-libs.x86_64               5.8.0-1.el7.elrepo            elrepo-kernel
kernel-ml-tools-libs-devel.x86_64         5.8.0-1.el7.elrepo            elrepo-kernel
perf.x86_64                               5.8.0-1.el7.elrepo            elrepo-kernel
python-perf.x86_64                        5.8.0-1.el7.elrepo            elrepo-kernel
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

4、如图可以看出,长期维护版本lt为4.4,最新主线稳定版ml为5.8,我们安装长期维护版本内核,使用如下命令:

 yum -y --enablerepo=elrepo-kernel install kernel-lt.x86_64  kernel-lt-devel.x86_64 
  • 1

已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * elrepo: mirrors.tuna.tsinghua.edu.cn
  • 1
  • 2
  • 3
  • 4
  • 5

5、查看内核默认启动顺序

 awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
  • 1
CentOS Linux (4.4.232-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-61e6672250f14dc4bb5130e77f9f621b) 7 (Core)
  • 1
  • 2
  • 3

如上,4.4版本内核目前位置为0,原来的3.10版本内核目前位置为1,所以需要修改内核启动顺序为0。在这里插入图片描述

vim /etc/default/grub

原本的GRUB_DEFAULT=saved改为GRUB_0=saved
  • 1
  • 2
  • 3

运行grub2-mkconfig命令来重新创建内核配置:

grub2-mkconfig -o /boot/grub2/grub.cfg
  • 1
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.232-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-4.4.232-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-61e6672250f14dc4bb5130e77f9f621b
Found initrd image: /boot/initramfs-0-rescue-61e6672250f14dc4bb5130e77f9f621b.img
done
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

6、重启

可以更新一下,到此内核升级完成
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/106421
推荐阅读
相关标签
  

闽ICP备14008679号