如何快速的将Centos6.7快速升级3.10.9

发布时间: 更新时间: 总字数:844 阅读时间:2m 作者: IP上海 分享 网址

在Centos6.5中,使用Docker等软件时需要升级内核,因此需要对Centos6.7(阿里云Centos系统)内核从2.6.32升级到3.10.90。当然使用源码安装十分麻烦,本博客主要如何采用RPM包升级内核。

kernel简介

在yum的ELRepo源中,有mainline(3.13.1)、long-term(3.10.90)这2个内核版本,考虑到long-term更稳定,会长期更新,所以本人推荐选择kernel-lt这个版本。

升级步骤

导入public key

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

安装ELRepo

rpm -ivh http://www.elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm

安装kernel-lt 3.10.90

这里的lt=long-term,这里推荐安装kt,下载地址:http://pan.baidu.com/s/1eQuJkcU。

yum --enablerepo=elrepo-kernel install kernel-lt -y

或者安装kernel-ml,ml=mainline。命令如下:

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

修改启动引导顺序

修改前:

[root@xiexianbin_cn ~]# vim /etc/grub.conf

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,0)
#          kernel /boot/vmlinuz-version ro root=/dev/xvda1
#          initrd /boot/initrd-[generic-]version.img
#boot=/dev/xvda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-573.7.1.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-573.7.1.el6.x86_64 ro root=UUID=94e4e384-0ace-437f-bc96-057dd64f42ee rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /boot/initramfs-2.6.32-573.7.1.el6.x86_64.img
title CentOS (2.6.32-431.23.3.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-431.23.3.el6.x86_64 ro root=UUID=94e4e384-0ace-437f-bc96-057dd64f42ee rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /boot/initramfs-2.6.32-431.23.3.el6.x86_64.img

修改后:

[root@xiexianbin_cn ~]# vim /etc/grub.conf

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,0)
#          kernel /boot/vmlinuz-version ro root=/dev/xvda1
#          initrd /boot/initrd-[generic-]version.img
#boot=/dev/xvda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.10.90-1.el6.elrepo.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-3.10.90-1.el6.elrepo.x86_64 ro root=UUID=94e4e384-0ace-437f-bc96-057dd64f42ee rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /boot/initramfs-3.10.90-1.el6.elrepo.x86_64.img
title CentOS (2.6.32-573.7.1.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-573.7.1.el6.x86_64 ro root=UUID=94e4e384-0ace-437f-bc96-057dd64f42ee rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /boot/initramfs-2.6.32-573.7.1.el6.x86_64.img
title CentOS (2.6.32-431.23.3.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-431.23.3.el6.x86_64 ro root=UUID=94e4e384-0ace-437f-bc96-057dd64f42ee rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /boot/initramfs-2.6.32-431.23.3.el6.x86_64.img

修改前,前确认新安装安装内核的位置,然后设置default值(从0开始),一般新安装的内核在第一个位置,所以设置default=0。

重启生效

升级前kernel版本:

[root@xiexianbin_cn ~]# uname -a
Linux xiexianbin_cn 2.6.32-573.7.1.el6.x86_64 #1 SMP Tue Sep 22 22:00:00 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

升级后kernel版本:

[root@xiexianbin_cn ~]# uname -a
Linux xiexianbin_cn 3.10.90-1.el6.elrepo.x86_64 #1 SMP Thu Oct 1 15:15:53 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux

更多内核下载地址

https://www.kernel.org/

可能存在的问题

遇到CentOs内核升级后,启动无法指定系统内核。原因是/etc/grub.conf和/boot/grub/grub.conf(为准)信息不同步导致。

cp -rf /boot/grub/grub.conf /etc/grub.conf
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数