升级CentOS内核 - 2.6升级到3.10/最新内核

##记得切换到root用户执行升级操作.
[root@localhost ~]# uname -a   ##旧版
Linux localhost.localdomain 2.6.32-279.el6.i686 #1 SMP Fri Jun 22 10:59:55 UTC 2012 i686 i686 i386 GNU/Linux
[root@localhost ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@localhost ~]# rpm -ivh https://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm
[root@localhost ~]# yum --enablerepo=elrepo-kernel install kernel-lt -y  ##此步会有点慢
[root@localhost ~]# vim /etc/grub.conf default=1 改为 default=0  ##设置默认以3.10核心启动,默认是按照旧的核心启动
[root@localhost ~]# reboot
[root@localhost ~]# uname -a  ##升级后的版本
Linux localhost.localdomain 3.10.104-1.el6.elrepo.i686 #1 SMP Fri Oct 21 09:11:59 EDT 2016 i686 i686 i386 GNU/Linux

网上有很多操作案例都失效的。

上面方法适用于centos6,如果是centos7则rpm文件替换为https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

 

2、修改grub的主配置文件/etc/grub.conf,设置default=0,表示第一个title下的内容为默认启动的kernel(一般新安装的内核在第一个位置),修改之后如下:

[root@localhost ~]# cat /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 have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/sda2
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.10.5-3.el6.x86_64)
 root (hd0,0)
 kernel /vmlinuz-3.10.5-3.el6.x86_64 ro root=UUID=78514585-1521-472c-8ca4-110fb82e9959 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 /initramfs-3.10.5-3.el6.x86_64.img
title CentOS (2.6.32-431.el6.x86_64)
 root (hd0,0)
 kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=UUID=78514585-1521-472c-8ca4-110fb82e9959 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 /initramfs-2.6.32-431.el6.x86_64.img

 

3、重启系统,这时候你的内核就成功升级了,执行uname -r

内核升级wiki:http://elrepo.org/tiki/tiki-index.php

方法二:

cd /etc/yum.repos.d
wget http://www.hop5.in/yum/el6/hop5.repo
yum install kernel-ml-aufs kernel-ml-aufs-devel -y

本方法没有测试过,有空再试试。

posted on 2018-09-29 01:46  佳宇博客  阅读(1609)  评论(0编辑  收藏  举报

导航