centos8.2升级kernel

Posted Docker云计算社区

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos8.2升级kernel相关的知识,希望对你有一定的参考价值。

前言

centos 8.2使用了grubby工具对kernel的启动顺序及kernel参数进行管理,具体用法可以参考文章末尾。


查看当前内核版本

[root@net_a mnt]# uname -aLinux net_a 4.18.0-193.el8.x86_64 #1 SMP Fri May 8 10:59:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux[root@net_a mnt]# uname -r4.18.0-193.el8.x86_64[root@net_a mnt]# cat /etc/redhat-release CentOS Linux release 8.2.2004 (Core) 

升级内核

启用 ELRepo 仓库

ELRepo 仓库是基于社区的用于企业级 Linux 仓库,提供对 RedHat Enterprise (RHEL) 和 其他基于 RHEL的 Linux 发行版(CentOS、Scientific、Fedora 等)的支持。

ELRepo 聚焦于和硬件相关的软件包,包括文件系统驱动、显卡驱动、网络驱动、声卡驱动和摄像头驱动等。


#导入ELRepo仓库的公共密钥

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

#安装ELRepo仓库的yum源

yum install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm

http://elrepo.org/tiki/HomePage

查看可用的系统内核包

root@net_a mnt]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list availableLast metadata expiration check: 3:03:56 ago on Sat 20 Feb 2021 11:28:56 AM CST.Available Packagesbpftool.x86_64 5.11.0-1.el8.elrepo elrepo-kernelkernel-lt.x86_64 5.4.99-1.el8.elrepo elrepo-kernelkernel-lt-core.x86_64 5.4.99-1.el8.elrepo elrepo-kernelkernel-lt-devel.x86_64 5.4.99-1.el8.elrepo elrepo-kernelkernel-lt-doc.noarch 5.4.99-1.el8.elrepo elrepo-kernelkernel-lt-headers.x86_64 5.4.99-1.el8.elrepo elrepo-kernelkernel-lt-modules.x86_64 5.4.99-1.el8.elrepo elrepo-kernelkernel-lt-modules-extra.x86_64 5.4.99-1.el8.elrepo elrepo-kernelkernel-lt-tools.x86_64 5.4.99-1.el8.elrepo elrepo-kernelkernel-lt-tools-libs.x86_64 5.4.99-1.el8.elrepo elrepo-kernelkernel-lt-tools-libs-devel.x86_64 5.4.99-1.el8.elrepo elrepo-kernelkernel-ml-devel.x86_64 5.11.0-1.el8.elrepo elrepo-kernelkernel-ml-doc.noarch 5.11.0-1.el8.elrepo elrepo-kernelkernel-ml-headers.x86_64 5.11.0-1.el8.elrepo elrepo-kernelkernel-ml-modules-extra.x86_64 5.11.0-1.el8.elrepo elrepo-kernelkernel-ml-tools.x86_64 5.11.0-1.el8.elrepo elrepo-kernelkernel-ml-tools-libs.x86_64 5.11.0-1.el8.elrepo elrepo-kernelkernel-ml-tools-libs-devel.x86_64 5.11.0-1.el8.elrepo elrepo-kernelperf.x86_64 5.11.0-1.el8.elrepo elrepo-kernelpython3-perf.x86_64 5.11.0-1.el8.elrepo elrepo-kernel[root@net_a mnt]#

安装最新版本内核


$ yum --enablerepo=elrepo-kernel install kernel-lt或者$ yum --enablerepo=elrepo-kernel install kernel-ml

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


设置启动顺序


查看当前所有kernel信息

[root@net_a mnt]# ls -l /boot/vmlinuz-*-rwxr-xr-x. 1 root root 8913656 Jan 22 10:28 /boot/vmlinuz-0-rescue-ad26eb6917944e649e631b2cad92c6c1-rwxr-xr-x. 1 root root 8913656 May 8 2020 /boot/vmlinuz-4.18.0-193.el8.x86_64-rwxr-xr-x  1 root root 9036576 Feb 15 07:31 /boot/vmlinuz-5.11.0-1.el8.elrepo.x86_64

查看5.11 kernel的详细信息

[root@net_a mnt]# grubby --info=/boot/vmlinuz-5.11.0-1.el8.elrepo.x86_64index=0kernel="/boot/vmlinuz-5.11.0-1.el8.elrepo.x86_64"args="ro console=ttyS0 console=tty0 net.ifnames=0 biosdevname=1"root="/dev/mapper/system-root"initrd="/boot/initramfs-5.11.0-1.el8.elrepo.x86_64.img"title="Red Hat Enterprise Linux (5.11.0-1.el8.elrepo.x86_64) 8.3 (Ootpa)"id="ad26eb6917944e649e631b2cad92c6c1-5.11.0-1.el8.elrepo.x86_64"

查看默认启动kernel参数,说明当前默认启动kernel为5.11.0-1

[root@net_a mnt]# grubby --default-index0

修改默认启动kernel项命令如下,当前先不修改,启动查看是否kernel为5.11.0-1

 grubby --set-default=/boot/vmlinuz-4.18.0-80.11.2.el8_0.x86_64

重启之后发现kernel已经替换

[root@net_a mnt]# uname -aLinux net_a 5.11.0-1.el8.elrepo.x86_64 #1 SMP Sun Feb 14 18:10:42 EST 2021 x86_64 x86_64 x86_64 GNU/Linux

参考:

其他命令:

[root@net_a mnt]# grubby --info=ALLindex=0kernel="/boot/vmlinuz-5.11.0-1.el8.elrepo.x86_64"args="ro console=ttyS0 console=tty0 net.ifnames=0 biosdevname=1"root="/dev/mapper/system-root"initrd="/boot/initramfs-5.11.0-1.el8.elrepo.x86_64.img"title="Red Hat Enterprise Linux (5.11.0-1.el8.elrepo.x86_64) 8.3 (Ootpa)"id="ad26eb6917944e649e631b2cad92c6c1-5.11.0-1.el8.elrepo.x86_64"index=1kernel="/boot/vmlinuz-4.18.0-193.el8.x86_64"args="ro console=ttyS0 console=tty0 net.ifnames=0 biosdevname=1"root="/dev/mapper/system-root"initrd="/boot/initramfs-4.18.0-193.el8.x86_64.img"title="CentOS Linux (4.18.0-193.el8.x86_64) 8 (Core)"id="ad26eb6917944e649e631b2cad92c6c1-4.18.0-193.el8.x86_64"index=2kernel="/boot/vmlinuz-0-rescue-ad26eb6917944e649e631b2cad92c6c1"args="ro console=ttyS0 console=tty0 net.ifnames=0 biosdevname=1"root="/dev/mapper/system-root"initrd="/boot/initramfs-0-rescue-ad26eb6917944e649e631b2cad92c6c1.img"title="CentOS Linux (0-rescue-ad26eb6917944e649e631b2cad92c6c1) 8 (Core)"id="ad26eb6917944e649e631b2cad92c6c1-0-rescue"
grubby --update-kernel=/boot/vmlinuz-4.18.0-80.7.1.el8_0.x86_64 --args=console=ttyS0,115200

帮助信息:

[root@net_a mnt]# grubby --helpUsage: grubby [OPTION...] --add-kernel=kernel-path add an entry for the specified kernel --args=args default arguments for the new kernel or new arguments for kernel being updated) --bad-image-okay don't sanity check images in boot entries (for testing only) -c, --config-file=path path to grub config file to update ("-" for stdin) --copy-default use the default boot entry as a template for the new entry being added; if the default is not a linux image, or if the kernel referenced by the default image does not exist, the first linux entry whose kernel does exist is used as the template --default-kernel display the path of the default kernel --default-index display the index of the default kernel --default-title display the title of the default kernel --env=path path for environment data --grub2 configure grub2 bootloader --info=kernel-path display boot information for specified kernel --initrd=initrd-path initrd image for the new kernel -i, --extra-initrd=initrd-path auxiliary initrd image for things other than the new kernel --make-default make the newly added entry the default boot entry --remove-args=STRING remove kernel arguments --remove-kernel=kernel-path remove all entries for the specified kernel --set-default=kernel-path make the first entry referencing the specified kernel the default --set-default-index=entry-index make the given entry index the default entry --title=entry-title title to use for the new kernel entry --update-kernel=kernel-path updated information for the specified kernel --zipl configure zipl bootloader -b, --bls-directory path to directory containing the BootLoaderSpec fragment files
Help options: -?, --help Show this help message


以上是关于centos8.2升级kernel的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu 升级/降级 Kernel 到指定版本

"arch/arm/kernel/head.S"里面一点片段的理解

CentOS升级kernel

CentOS6.4内核升级, 2.6.*版本升级 Kernel 3.10.*

ubuntu 升级到5.1kernel,打开bbr

记录一次升级kernel