如何升級centos7 內核方法 升級Centos 7/6內核版本到4.12.4的方法

 

關於內核說明:html

  版本性質:主分支ml(mainline),穩定版(stable),長期維護lt(longterm)python

  版本命名格式:「A.B.C"linux

    A表明內核版本號ios

    B表明內核主版本號web

    C表明內核次版本號chrome

 

1、檢查內核版本

[root@web1 ~]# uname -r
3.10.0-514.el7.x86_64
[root@web1 ~]# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 
[root@web1 ~]# 

2、如何升級內核

    這裏只關注centos7如何升級vim

 

  一、導入elrepo的key而後在安裝elrepo的yum源:centos

 

rpm -import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org ###key
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm   ###yum源

  

  二、查看可用的內核相關的包post

 

yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
 1 [root@web1 ~]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
 2 Loaded plugins: fastestmirror, langpacks
 3 elrepo-kernel                                                                                | 2.9 kB  00:00:00     
 4 elrepo-kernel/primary_db                                                                     | 1.8 MB  00:00:02     
 5 Loading mirror speeds from cached hostfile
 6  * elrepo-kernel: mirrors.tuna.tsinghua.edu.cn
 7 Available Packages
 8 kernel-lt.x86_64                                          4.4.180-2.el7.elrepo                         elrepo-kernel
 9 kernel-lt-devel.x86_64                                    4.4.180-2.el7.elrepo                         elrepo-kernel
10 kernel-lt-doc.noarch                                      4.4.180-2.el7.elrepo                         elrepo-kernel
11 kernel-lt-headers.x86_64                                  4.4.180-2.el7.elrepo                         elrepo-kernel
12 kernel-lt-tools.x86_64                                    4.4.180-2.el7.elrepo                         elrepo-kernel
13 kernel-lt-tools-libs.x86_64                               4.4.180-2.el7.elrepo                         elrepo-kernel
14 kernel-lt-tools-libs-devel.x86_64                         4.4.180-2.el7.elrepo                         elrepo-kernel
15 kernel-ml.x86_64                                          5.1.5-1.el7.elrepo                           elrepo-kernel
16 kernel-ml-devel.x86_64                                    5.1.5-1.el7.elrepo                           elrepo-kernel
17 kernel-ml-doc.noarch                                      5.1.5-1.el7.elrepo                           elrepo-kernel
18 kernel-ml-headers.x86_64                                  5.1.5-1.el7.elrepo                           elrepo-kernel
19 kernel-ml-tools.x86_64                                    5.1.5-1.el7.elrepo                           elrepo-kernel
20 kernel-ml-tools-libs.x86_64                               5.1.5-1.el7.elrepo                           elrepo-kernel
21 kernel-ml-tools-libs-devel.x86_64                         5.1.5-1.el7.elrepo                           elrepo-kernel
22 perf.x86_64                                               5.1.5-1.el7.elrepo                           elrepo-kernel
23 python-perf.x86_64                                        5.1.5-1.el7.elrepo                        

    

  三、安裝內核(我這裏用最新的吧)之後如何繼續升級直接用下面這條命令就能夠了ui

 

yum -y --enablerepo=elrepo-kernel install kernel-ml.x86_64 kernel-ml-devel.x86_64 

 

3、修改grub中默認的內核版本

 

  內核升級完成後,還須要調整

 

  一、查看內核啓動順序

 

 awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg

  經過此命令能夠看到新內核順序爲0

1 [root@web1 ~]# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
2 CentOS Linux (5.1.5-1.el7.elrepo.x86_64) 7 (Core)
3 CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core)
4 CentOS Linux (0-rescue-b7671beb75f14e95b5a58975dae3a897) 7 (Core)
5 You have new mail in /var/spool/mail/root
6 [root@web1 ~]# vim /etc/default/g
7 google-chrome  grub           

 

  二、修改內核啓動順序爲0

 

     vim /etc/default/grub 

1 [root@web1 ~]# vim /etc/default/grub 
2 
3 GRUB_TIMEOUT=5
4 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
5 GRUB_DEFAULT=0
6 GRUB_DISABLE_SUBMENU=true
7 GRUB_TERMINAL_OUTPUT="console"
8 GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0 "
9 GRUB_DISABLE_RECOVERY="true"

  

  三、接着用命令來建立內核配置

 

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

1 [root@web1 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
2 Generating grub configuration file ...
3 Found linux image: /boot/vmlinuz-5.1.5-1.el7.elrepo.x86_64
4 Found initrd image: /boot/initramfs-5.1.5-1.el7.elrepo.x86_64.img
5 Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64
6 Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img
7 Found linux image: /boot/vmlinuz-0-rescue-b7671beb75f14e95b5a58975dae3a897
8 Found initrd image: /boot/initramfs-0-rescue-b7671beb75f14e95b5a58975dae3a897.img
9 done

   

  四、重啓查看變化

 

      init 6或者reboot

[root@web1 ~]# init 6
[root@web1 ~]# uname -r
5.1.5-1.el7.elrepo.x86_64
[root@web1 ~]# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 
[root@web1 ~]# 

 

 

參考:升級Centos 7/6內核版本到4.12.4的方法,還介紹了沒法上網機器的升級方法

轉載請註明出處:http://www.javashuo.com/article/p-bqlihqja-do.html 

相關文章
相關標籤/搜索