Centos7设置内核启动顺序并删除多余内核 - 开发说
当前位置: 主页 » Centos » Centos7设置内核启动顺序并删除多余内核

Centos7设置内核启动顺序并删除多余内核

      2017年12月15日   阅读 1,562 次     0 评论   

有很多应用场景都需要最新的内核支持的一些新特性,比如BBR就需要最新的内核支持,那么问题来了,怎么升级内核并设置最新的内核默认启动呢?

升级内核,采用yum的方式:

#设置内核源:

Centos7    rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm  
Centos6    rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm

#升级内核:
yum --enablerepo=elrepo-kernel -y install kernel-ml kernel-ml-devel

#查看当前系统有几个内核:
[root@localhost~]#  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 (3.10.0-693.11.1.el7.x86_64) 7 (Core)' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-f4f03858-5d41-4445-a662-c5999f47bf2f' {
menuentry 'CentOS Linux (3.10.0-693.11.1.el7.x86_64) 7 (Core) with debugging' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-f4f03858-5d41-4445-a662-c5999f47bf2f' {
menuentry 'CentOS Linux (4.14.6-1.el7.elrepo.x86_64) 7 (Core)' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-f4f03858-5d41-4445-a662-c5999f47bf2f' {
menuentry 'CentOS Linux (4.14.6-1.el7.elrepo.x86_64) 7 (Core) with debugging' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-f4f03858-5d41-4445-a662-c5999f47bf2f' {
menuentry 'CentOS Linux (3.10.0-514.21.2.el7.x86_64) 7 (Core)' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-f4f03858-5d41-4445-a662-c5999f47bf2f' {
menuentry 'CentOS Linux (3.10.0-514.21.2.el7.x86_64) 7 (Core) with debugging' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-f4f03858-5d41-4445-a662-c5999f47bf2f' {
menuentry 'CentOS Linux (3.10.0-514.21.1.el7.x86_64) 7 (Core)' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-f4f03858-5d41-4445-a662-c5999f47bf2f' {
menuentry 'CentOS Linux (3.10.0-514.21.1.el7.x86_64) 7 (Core) with debugging' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-f4f03858-5d41-4445-a662-c5999f47bf2f' {
menuentry 'CentOS Linux (3.10.0-514.16.1.el7.x86_64) 7 (Core)' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-f4f03858-5d41-4445-a662-c5999f47bf2f' {
menuentry 'CentOS Linux (3.10.0-514.16.1.el7.x86_64) 7 (Core) with debugging' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-f4f03858-5d41-4445-a662-c5999f47bf2f' {
menuentry 'CentOS Linux 7 (Core), with Linux 0-rescue-31e871a0d760404d91649aecb7986bb3' --class rhel fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-31e871a0d760404d91649aecb7986bb3-advanced-f4f03858-5d41-4445-a662-c5999f47bf2f' {

Centos6 `sed -i 's/^default=.*/default=0/g' /boot/grub/grub.conf`
#以下操作Centos7为例,设置默认的启动内核为最新的内核:
[root@localhost ~]#  grub2-set-default "CentOS Linux (4.14.6-1.el7.elrepo.x86_64) 7 (Core)"
或者用`set grub2-set-default 0`

#验证是否修改成功:
[root@localhost ~]#  grub2-editenv list
saved_entry=CentOS Linux (4.14.6-1.el7.elrepo.x86_64) 7 (Core)

#重启系统,查看内核:
[root@localhost ~]# init 6
[root@localhost ~]# uname -r
4.14.6-1.el7.elrepo.x86_64
[root@localhost ~]# uname -a
Linux localhost 4.14.6-1.el7.elrepo.x86_64 #1 SMP Thu Dec 14 09:52:47 EST 2017 x86_64 x86_64 x86_64 GNU/Linux

#最新内核升级:
[root@localhost ~]# yum --enablerepo=elrepo-kernel -y update

可以看到有很多内核,那么如何安全删除多余的内核呢:

#查看系统内核:
[root@localhost ~]# rpm -qa | grep kernel
kernel-tools-3.10.0-693.11.1.el7.x86_64
kernel-3.10.0-514.21.2.el7.x86_64
kernel-ml-4.14.6-1.el7.elrepo.x86_64
kernel-3.10.0-514.21.1.el7.x86_64
kernel-ml-devel-4.14.6-1.el7.elrepo.x86_64
kernel-headers-3.10.0-693.11.1.el7.x86_64
kernel-tools-libs-3.10.0-693.11.1.el7.x86_64
kernel-3.10.0-693.11.1.el7.x86_64
kernel-3.10.0-514.16.1.el7.x86_64

#删除不必要的多余内核:
[root@localhost ~]# yum remove kernel-3.10.0-514.21.2.el7.x86_64 kernel-3.10.0-514.21.1.el7.x86_64 kernel-3.10.0-514.16.1.el7.x86_64
  • 版权声明:本文版权归开发说和原作者所有,未经许可不得转载。文章部分来源于网络仅代表作者看法,如有不同观点,欢迎进行交流。除非注明,文章均由 开发说 整理发布,欢迎转载,转载请带版权。

  • 来源:开发说 ( https://www.kaifashuo.com/ ),提供主机优惠信息深度测评和服务器运维编程技术。
  • 链接:https://www.kaifashuo.com/168.html
  • 评论(0

    1. 还没有任何评论,你来说两句吧

    发表回复

    您的电子邮箱地址不会被公开。 必填项已用 * 标注