如何安装并设置5.18.5-1.el8.elrepo.x86_64为新的默认内核?

如何安装并设置5.18.5-1.el8.elrepo.x86_64为新的默认内核?

这是 vCenter 上的虚拟机 (vmware)

当前内核3.10.0-862.el7.x86_64

[root@stage ~]# uname -a
Linux stage.dsr.FILTERED.net 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@stage ~]# hostnamectl
   Static hostname: stage.dsr.FILTERED.net
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 4121FILTERED1663
           Boot ID: b264FILTEREDa2dc
    Virtualization: vmware
  Operating System: CentOS Stream 8
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 3.10.0-862.el7.x86_64
      Architecture: x86-64

安装最新内核

sudo dnf --enablerepo=elrepo-kernel install kernel-ml kernel-ml-devel kernel-ml-headers
[root@stage ~]# sudo dnf --enablerepo=elrepo-kernel install kernel-ml kernel-ml-devel kernel-ml-headers
Last metadata expiration check: 0:36:34 ago on Tue 21 Jun 2022 23:59:55 BST.
Package kernel-ml-5.18.5-1.el8.elrepo.x86_64 is already installed.
Package kernel-ml-devel-5.18.5-1.el8.elrepo.x86_64 is already installed.
Package kernel-ml-headers-5.18.5-1.el8.elrepo.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

检查可用图像/boot

[root@stage boot]# ls -al
total 91212
dr-xr-xr-x.  6 root root      272 Jun 22 00:06 .
dr-xr-xr-x. 17 root root      224 Jun 22 00:01 ..
drwxr-xr-x.  3 root root       17 Aug 30  2018 efi
drwxr-xr-x.  2 root root        6 Jun 22 00:07 grub
drwx------.  5 root root      156 Jun 21 23:48 grub2
-rw-------.  1 root root 55388571 Aug 30  2018 initramfs-0-rescue-4121a368f8744621872224e7593f1663.img
-rw-------.  1 root root 12508372 Jun  7 18:44 initramfs-3.10.0-862.el7.x86_64kdump.img
-rw-------.  1 root root 19272908 Jun 22 00:06 initramfs-5.18.5-1.el8.elrepo.x86_64.img
drwxr-xr-x.  3 root root       21 Jun 21 23:48 loader
-rwxr-xr-x.  1 root root  6224704 Aug 30  2018 vmlinuz-0-rescue-4121a368f8744621872224e7593f1663

列出默认内核

[root@stage boot]# grubby --default-kernel
/boot/vmlinuz-0-rescue-4121a368f8744621872224e7593f1663

列出可用的

[root@stage boot]# ls -l /boot/vmlinuz-*
-rwxr-xr-x. 1 root root 6224704 Aug 30  2018 /boot/vmlinuz-0-rescue-4121a368f8744621872224e7593f1663

只有一个条目!

列出 RPM 内核包

[root@stage boot]# rpm -qa | grep kernel
kernel-ml-devel-5.18.5-1.el8.elrepo.x86_64
kernel-ml-headers-5.18.5-1.el8.elrepo.x86_64
kernel-ml-modules-5.18.5-1.el8.elrepo.x86_64
kernel-ml-5.18.5-1.el8.elrepo.x86_64
kernel-ml-core-5.18.5-1.el8.elrepo.x86_64

如何安装并设置5.18.5-1.el8.elrepo.x86_64为新的默认内核?

欢迎任何指点

更新20220622

[root@stage ~]# dracut --force
dracut: Cannot find module directory /lib/modules/3.10.0-862.el7.x86_64/
dracut: and --no-kernel was not specified

也尝试过

dracut --kver 5.18.5-1.el8.elrepo.x86_64 --force
dracut --regenerate-all --force

但我的文件夹vmlinuz-中仍然只有一个相同的/boot

[root@stage boot]# ls -al
drwxr-xr-x.  3 root root       17 Aug 30  2018 efi
drwxr-xr-x.  2 root root        6 Jun 22 00:07 grub
drwx------.  5 root root      156 Jun 22 16:44 grub2
-rw-------.  1 root root 55388571 Aug 30  2018 initramfs-0-rescue-4121a368f8744621872224e7593f1663.img
-rw-------.  1 root root 12508372 Jun  7 18:44 initramfs-3.10.0-862.el7.x86_64kdump.img
-rw-------.  1 root root 19457348 Jun 22 17:32 initramfs-5.18.5-1.el8.elrepo.x86_64.img
drwxr-xr-x.  3 root root       21 Jun 21 23:48 loader
-rwxr-xr-x.  1 root root  6224704 Aug 30  2018 vmlinuz-0-rescue-4121a368f8744621872224e7593f1663

答案1

看来内核文件丢失了。

尝试重新安装内核

dnf remove kernel-ml
dnf --enablerepo=elrepo-kernel install kernel-ml

内核 5.x 应该是默认设置的。

验证它通过

grubby --default-kernel

如果没有,请手动设置

grubby --set-default /boot/vmlinuz-5.xxx.el8.elrepo.x86_64

答案2

尝试dracut --forcegrub2-mkconfig

相关内容