升级CentOS内核 - 2.6升级到3.10/最新内核
程序员文章站
2022-06-19 20:53:59
网上有很多操作案例都失效的。 上面方法适用于centos6,如果是centos7则rpm文件替换为https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm 2、修改grub的主配置文件/etc/grub.conf,设置defa ......
##记得切换到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
本方法没有测试过,有空再试试。