Centos7.X内核升级

安装EPEL源

# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# yum install -y https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm

内核升级

查看内核版本并安装最新版本(这里安装LT长期支持的版本 5.4.259 )
# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
Loaded plugins: fastestmirror
Determining fastest mirrors
 * elrepo-kernel: mirrors.tuna.tsinghua.edu.cn
elrepo-kernel                                                                                                                           | 3.0 kB  00:00:00     
elrepo-kernel/primary_db                                                                                                                | 2.1 MB  00:00:00     
Available Packages
kernel-lt.x86_64                                                               5.4.259-1.el7.elrepo                                               elrepo-kernel
kernel-lt-devel.x86_64                                                         5.4.259-1.el7.elrepo                                               elrepo-kernel
kernel-lt-doc.noarch                                                           5.4.259-1.el7.elrepo                                               elrepo-kernel
kernel-lt-headers.x86_64                                                       5.4.259-1.el7.elrepo                                               elrepo-kernel
kernel-lt-tools.x86_64                                                         5.4.259-1.el7.elrepo                                               elrepo-kernel
kernel-lt-tools-libs.x86_64                                                    5.4.259-1.el7.elrepo                                               elrepo-kernel
kernel-lt-tools-libs-devel.x86_64                                              5.4.259-1.el7.elrepo                                               elrepo-kernel
kernel-ml.x86_64                                                               6.5.9-1.el7.elrepo                                                 elrepo-kernel
kernel-ml-devel.x86_64                                                         6.5.9-1.el7.elrepo                                                 elrepo-kernel
kernel-ml-doc.noarch                                                           6.5.9-1.el7.elrepo                                                 elrepo-kernel
kernel-ml-headers.x86_64                                                       6.5.9-1.el7.elrepo                                                 elrepo-kernel
kernel-ml-tools.x86_64                                                         6.5.9-1.el7.elrepo                                                 elrepo-kernel
kernel-ml-tools-libs.x86_64                                                    6.5.9-1.el7.elrepo                                                 elrepo-kernel
kernel-ml-tools-libs-devel.x86_64                                              6.5.9-1.el7.elrepo                                                 elrepo-kernel
perf.x86_64                                                                    5.4.259-1.el7.elrepo                                               elrepo-kernel
python-perf.x86_64                                                             5.4.259-1.el7.elrepo                                               elrepo-kerne

安装最新的LT内核版本:
# yum --disablerepo='*' --enablerepo=elrepo-kernel install kernel-lt kernel-lt-devel -y
查看系统 grub2 内核启动列表,编号0的内核版本为 5.4.259 ,是上面新安装的:
#  awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
0 : CentOS Linux (5.4.259-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-1160.53.1.el7.x86_64) 7 (Core)
2 : CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
3 : CentOS Linux (0-rescue-170d9a863c7543f3b6a9e41c3eeee2d0) 7 (Core)
更改系统内核启动顺序,生成 grub2 配置文件:
# grub2-set-default 0 && grub2-mkconfig -o /etc/grub2.cfg
# grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)"
检查默认内核是不是 5.4.259 :
# grubby --default-kernel
/boot/vmlinuz-5.4.259-1.el7.elrepo.x86_64

验证

系统重启后,检查系统当前内核是不是 5.4.259 :

# uname -r
5.4.259-1.el7.elrepo.x86_64
文档更新时间: 2023-11-01 16:05   作者:xtyang