CentOS7升级内核

CentOS7升级内核

首先看下当前系统内核版本

1
2
3
4
[root@test_yc ~]# uname -r
3.10.0-862.el7.x86_64
[root@test_yc ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

安装elrepo的yum源:

1
2
$ rpm -import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
$ rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm

查看可以安装的内核的包:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@test_yc ~]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* elrepo-kernel: mirrors.neusoft.edu.cn
可安装的软件包
kernel-lt.x86_64 4.4.176-1.el7.elrepo elrepo-kernel
kernel-lt-devel.x86_64 4.4.176-1.el7.elrepo elrepo-kernel
kernel-lt-doc.noarch 4.4.176-1.el7.elrepo elrepo-kernel
kernel-lt-headers.x86_64 4.4.176-1.el7.elrepo elrepo-kernel
kernel-lt-tools.x86_64 4.4.176-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs.x86_64 4.4.176-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs-devel.x86_64 4.4.176-1.el7.elrepo elrepo-kernel
kernel-ml-devel.x86_64 5.0.3-1.el7.elrepo elrepo-kernel
kernel-ml-doc.noarch 5.0.3-1.el7.elrepo elrepo-kernel
kernel-ml-headers.x86_64 5.0.3-1.el7.elrepo elrepo-kernel
kernel-ml-tools.x86_64 5.0.3-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 5.0.3-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 5.0.3-1.el7.elrepo elrepo-kernel
perf.x86_64 5.0.3-1.el7.elrepo elrepo-kernel
python-perf.x86_64 5.0.3-1.el7.elrepo elrepo-kernel

安装内核及修改相关配置

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

修改grub中默认的内核启动顺序,将GRUB_DEFAULT=saved 改为 GRUB_DEFAULT=0

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

重新创建内核配置

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

重启生效

1
$ reboot

重启之后查看系统内核版本,升级内核完毕。

1
2
[root@test_yc ~]# uname -r
5.0.3-1.el7.elrepo.x86_64

-------------本文结束感谢您的阅读-------------