Centos7升级内核
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7升级内核相关的知识,希望对你有一定的参考价值。
参考技术A uname -aLinux localhost.localdomain 3.10.0-1160.25.1.el7.x86_64 #1 SMP Wed Apr 28 21:49:45 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all && yum -y update
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
$ yum --enablerepo=elrepo-kernel install kernel-ml
内核安装好后,需要设置为默认启动选项并重启后才会生效
1=="menuentry " print i++ " : " $2' /etc/grub2.cfg
0 : CentOS Linux (5.12.1-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-1160.25.1.el7.x86_64) 7 (Core)
2 : CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core)
3 : CentOS Linux (0-rescue-16ba4d58b7b74338bfd60f5ddb0c8483) 7 (Core)
服务器上存在4 个内核,我们要使用 5.12.1这个版本,可以通过 grub2-set-default 0 命令或编辑 /etc/default/grub 文件来设置
其中 0 是上面查询出来的可用内核
grub2-set-default 0
设置 GRUB_DEFAULT=0,通过上面查询显示的编号为 0 的内核作为默认内核:
(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=cl/root rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
$ grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.12.1-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-5.12.1-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.25.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.25.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-16ba4d58b7b74338bfd60f5ddb0c8483
Found initrd image: /boot/initramfs-0-rescue-16ba4d58b7b74338bfd60f5ddb0c8483.img
done
$ reboot
$ uname -r 5.12.1-1.el7.elrepo.x86_64
以上是关于Centos7升级内核的主要内容,如果未能解决你的问题,请参考以下文章