Grub 无法获取新内核(原为:如何更新 Fedora 内核)

Grub 无法获取新内核(原为:如何更新 Fedora 内核)

为了让 Vagrant 正常工作,我似乎无休止地尝试更新 Fedora。Vagrant 需要 VirtualBox,VirtualBox 需要内核源,而内核源仅适用于最新内核版本。

$ uname -r
4.3.5-300.fc23.x86_64

我尝试更新系统。

$ sudo dnf update
Last metadata expiration check: 2:03:57 ago on Tue May 10 11:20:17 2016.
Dependencies resolved.
Nothing to do.
Complete!

显然系统已经更新。

$ sudo dnf install kernel

Last metadata expiration check: 2:05:00 ago on Tue May 10 11:20:17 2016.
Package kernel-4.4.8-300.fc23.x86_64 is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!

我尝试删除当前内核:

$ sudo dnf 删除内核-(uname -r)

完成。让我们看看安装了什么:

$ rpm -qva "kernel-*"
kernel-core-4.4.8-300.fc23.x86_64
kernel-core-4.4.4-301.fc23.x86_64
kernel-headers-4.4.8-300.fc23.x86_64
kernel-modules-4.4.8-300.fc23.x86_64
kernel-devel-4.4.8-300.fc23.x86_64
kernel-modules-4.4.4-301.fc23.x86_64

到目前为止一切都很好。

所以我重新启动了....

却发现 Grub 中列出了三个内核:4.3.5-300.fc23.x86_64,以及来自 4.2 分支的两个更旧的内核。

$ rpm -qva "kernel-*"
kernel-modules-4.3.5-300.fc23.x86_64
kernel-core-4.4.8-300.fc23.x86_64
kernel-core-4.4.4-301.fc23.x86_64
kernel-core-4.3.5-300.fc23.x86_64
kernel-headers-4.4.8-300.fc23.x86_64
kernel-modules-4.4.8-300.fc23.x86_64
kernel-devel-4.4.8-300.fc23.x86_64
kernel-modules-4.4.4-301.fc23.x86_64

这到底发生了什么事?

编辑:我后来尝试更新 grub 以获取新内核。

$ cd /boot/grub2
$ mv grub.cfg grub.cfg.old
$ sudo grub2-mkconfig -o grub.cfg.new
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.8-300.fc23.x86_64
Found initrd image: /boot/initramfs-4.4.8-300.fc23.x86_64.img
Found linux image: /boot/vmlinuz-4.4.4-301.fc23.x86_64
Found initrd image: /boot/initramfs-4.4.4-301.fc23.x86_64.img
Found linux image: /boot/vmlinuz-4.3.5-300.fc23.x86_64
Found initrd image: /boot/initramfs-4.3.5-300.fc23.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-0468365313db460f867aa0a7c6284ace
Found initrd image: /boot/initramfs-0-rescue-0468365313db460f867aa0a7c6284ace.img

我可以确认新的配置文件具有正确的条目:

 $ grep 4.4 grub.cfg
  menuentry 'Fedora (4.4.8-300.fc23.x86_64) 23 (Workstation Edition)' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.3.5-300.fc23.x86_64-advanced-29e2d74b-255e-44fa-b8e7-edb54b33f225' {
linux16 /vmlinuz-4.4.8-300.fc23.x86_64 root=/dev/mapper/fedora_deepwinter-root ro rd.lvm.lv=fedora_deepwinter/root rd.luks.uuid=luks-b09d62d7-9782-42d5-890d-f117ccb8a1cc rd.lvm.lv=fedora_deepwinter/swap rhgb quiet splash acpi_backlight=vendor acpi_osi='!Windows 2013' acpi_osi='!Windows 2012' LANG=en_GB.UTF-8
initrd16 /initramfs-4.4.8-300.fc23.x86_64.img
    menuentry 'Fedora (4.4.4-301.fc23.x86_64) 23 (Workstation Edition)' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.3.5-300.fc23.x86_64-advanced-29e2d74b-255e-44fa-b8e7-edb54b33f225' {
linux16 /vmlinuz-4.4.4-301.fc23.x86_64 root=/dev/mapper/fedora_deepwinter-root ro  rd.lvm.lv=fedora_deepwinter/root rd.luks.uuid=luks-b09d62d7-9782-42d5-890d-f117ccb8a1cc rd.lvm.lv=fedora_deepwinter/swap rhgb quiet splash acpi_backlight=vendor acpi_osi='!Windows 2013' acpi_osi='!Windows 2012' LANG=en_GB.UTF-8
initrd16 /initramfs-4.4.4-301.fc23.x86_64.img

现在,我没有进行双启动或任何类似复杂的操作。我有一个硬盘,上面安装了一个 Fedora。为什么 grub.cfg 有正确的条目,但当我重新启动计算机时,它仍然显示 4.2.4、4.2.3 和 4.3.5?这可能是多个 /boots 的挂载点问题吗?

$ mount | grep boot
/dev/sda2 on /boot type ext4 (rw,relatime,seclabel,data=ordered)

$ ls /dev/ | grep sd
sda
sda1
sda2
sda3
sda4

内核文件肯定存在:

$ ls /boot | grep 4.4
config-4.4.4-301.fc23.x86_64
config-4.4.8-300.fc23.x86_64
initramfs-4.4.4-301.fc23.x86_64.img
initramfs-4.4.8-300.fc23.x86_64.img
System.map-4.4.4-301.fc23.x86_64
System.map-4.4.8-300.fc23.x86_64
vmlinuz-4.4.4-301.fc23.x86_64
vmlinuz-4.4.8-300.fc23.x86_64

也许我应该尝试将 grub 重新安装到硬盘中...

$ sudo grub2-install --target=/dev/sda
grub2-install: error: /usr/lib/grub/dev/sda/modinfo.sh doesn't exist. Please specify --target or --directory.
$ sudo grub2-install --directory=/boot
grub2-install: error: /boot/modinfo.sh doesn't exist. Please specify --target or --directory.

我不知道 modinfo.sh 是什么,但它看起来很重要......

此刻我并不太清楚为什么 Grub 没有获取内核或者它从哪里加载配置。

相关内容