本文以centos 7.0为例,内核版本为3.10.0-123.el7.x86_64,升级到内核版本为3.10.0-123.1.2.el7.x86_64。
centos 7
1.查看当前系统版本信息
[root@centos70-1406 ~]# uname -sr
Linux 3.10.0-123.el7.x86_64
2.在网站:https://vault.centos.org/里面下载Binary package二进制包
注:https://vault.centos.org/网站如果进不去了,可以用https://mirrors.tripadvisor.com/centos-vault/网站或者在http://rpm.pbone.net/网站的输入框中输入kernel版本,直接搜索,下载。
因为我是centos7.0版本,所以点击7.0.1406
选择updates
选择x86_64
选择Packages
可以看到如下页面
3.按Ctrl+f在页面上进行查找,输入kernel,一路回车,找到你需要的kernel版本。
这里我需要的是3.10.0-123.1.2.el7.x86_64,点击,对应的rpm包就被下载到电脑上了。
4.将这个包上传到centos中
5.安装下载的内核:kernel-3.10.0-123.1.2.el7.x86_64.rpm
[root@centos70-1406 ~]# yum install kernel-3.10.0-123.1.2.el7.x86_64.rpm
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Examining kernel-3.10.0-123.1.2.el7.x86_64.rpm: kernel-3.10.0-123.1.2.el7.x86_64
Marking kernel-3.10.0-123.1.2.el7.x86_64.rpm as an update to kernel-3.10.0-123.el7.x86_64
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:3.10.0-123.1.2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================
Package Arch Version Repository Size
====================================================================================================================
Installing:
kernel x86_64 3.10.0-123.1.2.el7 /kernel-3.10.0-123.1.2.el7.x86_64 127 M
Transaction Summary
====================================================================================================================
Install 1 Package
Total size: 127 M
Installed size: 127 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : kernel-3.10.0-123.1.2.el7.x86_64 1/1
Verifying : kernel-3.10.0-123.1.2.el7.x86_64 1/1
Installed:
kernel.x86_64 0:3.10.0-123.1.2.el7
Complete!
6.查看默认启动顺序
[root@centos70-1406 ~]# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
CentOS Linux (3.10.0-123.1.2.el7.x86_64) 7 (Core)
CentOS Linux, with Linux 3.10.0-123.el7.x86_64
CentOS Linux, with Linux 0-rescue-1809df64d0464347b38daeeb523d7429
7.默认启动的顺序是从0开始,新内核是从头插入的,所以需要选择0。若是这个命令报错,则可省略该命令,直接到下一步。
[root@centos70-1406 ~]# grub2-set-default 0
8.然后reboot重启,使用新的内核
[root@centos70-1406 ~]# uname -sr
Linux 3.10.0-123.1.2.el7.x86_64
注:****************************************************************************************************************
centos 6
1.若是centos 6升级或降级到指定kernel,在安装时可能会报错,原因是除了kernel-X.X.X-X.X.X.x86_64.rpm包,还需要对应的kernel-firmware-X.X.X-X.X.X.X.noarch.RPM的包。
Error Downloading Packages:
kernel-firmware-2.6.32-754.29.2.el6.noarch: failure: Packages/kernel-firmware-2.6.32-754.29.2.el6.noarch.rpm from updates: [Errno 256] No more mirrors to try.
仍旧是在网站:https://vault.centos.org/里面找到对应的目录下载。
下面以centos 6.0从2.6.32-71.el6.x86_64升级到2.6.32-71.7.1.el6.x86_64为例。
在https://vault.centos.org/6.0/updates/x86_64/RPMS/页面找到kernel-2.6.32-71.7.1.el6.x86_64.rpm和kernel-firmware-2.6.32-71.7.1.el6.noarch.rpm包,下载。
2.安装kernel-2.6.32-71.7.1.el6.x86_64.rpm和kernel-firmware-2.6.32-71.7.1.el6.noarch.rpm
[root@centos60 ~]# yum install kernel-2.6.32-71.7.1.el6.x86_64.rpm kernel-firmware-2.6.32-71.7.1.el6.noarch.rpm
3.默认启动的顺序是从0开始,新内核是从头插入的,所以需要选择0。若是这个命令报错,则可省略该命令,直接到下一步。
[root@centos60 ~]# grub2-set-default 0
4.然后reboot重启,使用新的内核
[root@centos60 ~]# uname -sr
Linux 2.6.32-71.7.1.el6.x86_64