Grub 不显示 xanmod 内核

Grub 不显示 xanmod 内核

我已经在 Ubuntu 20.04 上安装了 xanmod 内核(5.13),但它没有出现在 grub 菜单中。

$ ls -la /boot
total 374776
drwxr-xr-x  5 root root      4096 Sep 11 11:44 .
drwxr-xr-x 20 root root      4096 Aug 11  2020 ..
-rw-r--r--  1 root root    251162 Apr 16 11:35 config-5.11.15-051115-generic
-rw-r--r--  1 root root    256848 Sep  8 15:52 config-5.13.15-xanmod1
-rw-r--r--  1 root root    237769 Sep 10  2020 config-5.4.0-48-generic
drwx------  3 root root      4096 Jan  1  1970 efi
drwxr-xr-x  5 root root      4096 Sep 11 12:17 grub
lrwxrwxrwx  1 root root        33 Sep  5 14:47 initrd.img -> initrd.img-5.11.15-051115-generic
-rw-r--r--  1 root root  95484965 Sep 11 11:41 initrd.img-5.11.15-051115-generic
-rw-r--r--  1 root root 154095831 Sep 11 11:42 initrd.img-5.13.15-xanmod1
-rw-r--r--  1 root root  82174073 Sep 11 11:41 initrd.img-5.4.0-48-generic
lrwxrwxrwx  1 root root        27 Sep  5 14:47 initrd.img.old -> initrd.img-5.4.0-48-generic
drwx------  2 root root     16384 Aug 11  2020 lost+found
-rw-r--r--  1 root root    182704 Aug 18  2020 memtest86+.bin
-rw-r--r--  1 root root    184380 Aug 18  2020 memtest86+.elf
-rw-r--r--  1 root root    184884 Aug 18  2020 memtest86+_multiboot.bin
-rw-------  1 root root   5954147 Apr 16 11:35 System.map-5.11.15-051115-generic
-rw-r--r--  1 root root   4762070 Sep  8 15:52 System.map-5.13.15-xanmod1
-rw-------  1 root root   4743112 Sep 10  2020 System.map-5.4.0-48-generic
lrwxrwxrwx  1 root root        30 Sep  5 14:47 vmlinuz -> vmlinuz-5.11.15-051115-generic
-rw-------  1 root root  14336896 Apr 16 11:35 vmlinuz-5.11.15-051115-generic
-rw-r--r--  1 root root   9162976 Sep  8 15:52 vmlinuz-5.13.15-xanmod1
-rw-------  1 root root  11678464 Sep 10  2020 vmlinuz-5.4.0-48-generic
lrwxrwxrwx  1 root root        24 Sep  5 14:47 vmlinuz.old -> vmlinuz-5.4.0-48-generic

$ sudo update-grub2
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.11.15-051115-generic
Found initrd image: /boot/initrd.img-5.11.15-051115-generic
Found linux image: /boot/vmlinuz-5.11.15-051115-generic
Found initrd image: /boot/initrd.img-5.11.15-051115-generic
Found linux image: /boot/vmlinuz-5.4.0-48-generic
Found initrd image: /boot/initrd.img-5.4.0-48-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
done

看起来update-grub2(也update-grub) 两次检测内核 5.11,而根本没有检测 xanmod 内核 5.13?为什么会这样?

答案1

如果你安装了 debian lowlatency 内核,那么文件 /etc/grub.d/09_lowlatency 会阻止 update-grub 看到 xanmod 内核

方法 1 删除低延迟内核:

sudo apt remove linux-image-lowlatency

方法2 在/etc/grub.d中创建一个新模块:

sudo cp /etc/grub.d/09_lowlatency /etc/grub.d/08_xanmod
sudo vi /etc/grub.d/08_xanmod

在 /etc/grub.d/08_xanmod 中添加以下内容

--- /etc/grub.d/09_lowlatency   2021-06-25 19:34:13.000000000 -0700
+++ /etc/grub.d/08_xanmod       2022-01-16 06:56:27.014767317 -0800
@@ -36,6 +36,11 @@
 export TEXTDOMAIN=grub
 export TEXTDOMAINDIR="${datarootdir}/locale"
 
+# only 08_xanmod or 09_lowlatency should run, since we got this far
+# 09_lowlatency should not run next
+if [ -x /etc/grub.d/09_lowlatency ]; then
+  chmod -x /etc/grub.d/09_lowlatency
+fi
 # only 09_lowlatency or 10_linux should run, since we got this far
 # 10_linux should not run next
 if [ -x /etc/grub.d/10_linux ]; then
@@ -247,6 +252,9 @@
 case "x$machine" in
     xi?86 | xx86_64)
        list=
+       for i in /boot/vmlinuz-*xanmod1; do
+           if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
+        done
        for i in /boot/vmlinuz-*lowlatency /vmlinuz-*lowlatency /boot/kernel-*lowlatency ; do
            if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
        done

最后使用新模块更新 grub conf

sudo update-grub2

相关内容