首页 > Linux > Centos7 升级内核版本
2021
08-31

Centos7 升级内核版本

1、查看当前内核版本

 

uname -r
3.10.0-957.el7.x86_64

 

2、升级内核

更新yum源仓库

 

yum -y update
启用 ELRepo 仓库

 

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

rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

 

3、查看可用的系统内核包

 

yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
 
Loaded plugins: fastestmirror
Determining fastest mirrors
 * elrepo-kernel: elrepo.org
elrepo-kernel                                                                                                                                                                                          | 3.0 kB  00:00:00     
elrepo-kernel/primary_db                                                                                                                                                                               | 2.0 MB  00:00:27     
Available Packages
elrepo-release.noarch                                                                                          7.0-5.el7.elrepo                                                                                  elrepo-kernel
kernel-lt.x86_64                                                                                               5.4.143-1.el7.elrepo                                                                              elrepo-kernel
kernel-lt-devel.x86_64                                                                                         5.4.143-1.el7.elrepo                                                                              elrepo-kernel
kernel-lt-doc.noarch                                                                                           5.4.143-1.el7.elrepo                                                                              elrepo-kernel
kernel-lt-headers.x86_64                                                                                       5.4.143-1.el7.elrepo                                                                              elrepo-kernel
kernel-lt-tools.x86_64                                                                                         5.4.143-1.el7.elrepo                                                                              elrepo-kernel
kernel-lt-tools-libs.x86_64                                                                                    5.4.143-1.el7.elrepo                                                                              elrepo-kernel
kernel-lt-tools-libs-devel.x86_64                                                                              5.4.143-1.el7.elrepo                                                                              elrepo-kernel
kernel-ml.x86_64                                                                                               5.14.0-1.el7.elrepo                                                                               elrepo-kernel
kernel-ml-devel.x86_64                                                                                         5.14.0-1.el7.elrepo                                                                               elrepo-kernel
kernel-ml-doc.noarch                                                                                           5.14.0-1.el7.elrepo                                                                               elrepo-kernel
kernel-ml-headers.x86_64                                                                                       5.14.0-1.el7.elrepo                                                                               elrepo-kernel
kernel-ml-tools.x86_64                                                                                         5.14.0-1.el7.elrepo                                                                               elrepo-kernel
kernel-ml-tools-libs.x86_64                                                                                    5.14.0-1.el7.elrepo                                                                               elrepo-kernel
kernel-ml-tools-libs-devel.x86_64                                                                              5.14.0-1.el7.elrepo                                                                               elrepo-kernel
perf.x86_64                                                                                                    5.14.0-1.el7.elrepo                                                                               elrepo-kernel
python-perf.x86_64                                                                                             5.14.0-1.el7.elrepo                                                                               elrepo-kernel

 

 

4、安装最新版本内核

#--enablerepo 选项开启 CentOS 系统上的指定仓库。默认开启的是 elrepo,这里用 elrepo-kernel 替换。

//升级内核,参考https://elrepo.org/linux/kernel/el7/x86_64/RPMS/ 里显示的 elrepo-release的版本进行如下第2步的安装

//lt:长期维护版本  kernel-lt

//ml:最新主线稳定版  kernel-ml

yum -y --enablerepo=elrepo-kernel install kernel-lt.x86_64 kernel-lt-devel.x86_64

 

5、设置 grub2

内核安装好后,需要设置为默认启动选项并重启后才会生效

查看系统上的所有可用内核:

 

sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg

0 : CentOS Linux (5.4.143-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
2 : CentOS Linux (0-rescue-016418f3b9ca495e89d5826f869f8170) 7 (Core)

 

修改默认内核:

#方法1:

grub2-set-default 0

#方法2:

vim /etc/default/grub


GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=0 #修改此处
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

 

重新生成grub配置:

 

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

 

 Centos7 升级内核版本 - 第1张  | 技术人生

最后编辑:
作者:sunny5156
喜欢技术....

留下一个回复