update-grub 不会将所有内核添加到 grub 菜单

update-grub 不会将所有内核添加到 grub 菜单

Ubuntu 21.10。

我正在按照以下文档构建内核https://help.ubuntu.com/community/Kernel/Compilehttps://wiki.ubuntu.com/Kernel/BuildYourOwnKernel

DEB_BUILD_OPTIONS=parallel=$(getconf _NPROCESSORS_ONLN) AUTOBUILD=1 NOEXTRAS=1 \
    fakeroot debian/rules binary-arch

该编译命令有相同的结果:

make --jobs=$(getconf _NPROCESSORS_ONLN) bindeb-pkg \
    LOCALVERSION=-custom-$(git describe | tr '[:upper:]' '[:lower:]')

这将创建一些.deb包:

$ ls -hal ../*.deb
-rw-r--r-- 1 amedee amedee 8,2M feb 26 02:17 ../linux-headers-5.13.19-ubuntu-5.13.0-22.22_5.13.19-ubuntu-5.13.0-22.22-6_amd64.deb
-rw-r--r-- 1 amedee amedee  70M feb 26 02:18 ../linux-image-5.13.19-ubuntu-5.13.0-22.22_5.13.19-ubuntu-5.13.0-22.22-6_amd64.deb
-rw-r--r-- 1 amedee amedee 1,2M feb 26 02:17 ../linux-libc-dev_5.13.19-ubuntu-5.13.0-22.22-6_amd64.deb

我像这样安装它们:

sudo dpkg --install \
    ../linux-headers-5.13.19-ubuntu-5.13.0-22.22_5.13.19-ubuntu-5.13.0-22.22-6_amd64.deb \
    ../linux-image-5.13.19-ubuntu-5.13.0-22.22_5.13.19-ubuntu-5.13.0-22.22-6_amd64.deb

其内容如下/boot

$ ls -hal /boot/*5.13*
-rw-r--r-- 1 root root 252K nov  5 10:21 /boot/config-5.13.0-22-generic
-rw-r--r-- 1 root root 251K feb 26 02:15 /boot/config-5.13.19-ubuntu-5.13.0-22.22
-rw-r--r-- 1 root root  40M feb 22 16:21 /boot/initrd.img-5.13.0-22-generic
-rw-r--r-- 1 root root  37M feb 26 02:20 /boot/initrd.img-5.13.19-ubuntu-5.13.0-22.22
-rw------- 1 root root 5,7M nov  5 10:21 /boot/System.map-5.13.0-22-generic
-rw-r--r-- 1 root root 5,6M feb 26 02:15 /boot/System.map-5.13.19-ubuntu-5.13.0-22.22
-rw------- 1 root root 9,8M nov  5 13:51 /boot/vmlinuz-5.13.0-22-generic
-rw-r--r-- 1 root root 8,5M feb 26 02:15 /boot/vmlinuz-5.13.19-ubuntu-5.13.0-22.22

更新 initramfs(严格来说这不是必需的,因为已经完成了,但为了保险起见):

$ sudo update-initramfs -u -k all
update-initramfs: Generating /boot/initrd.img-5.13.19-ubuntu-5.13.0-22.22
update-initramfs: Generating /boot/initrd.img-5.13.0-22-generic

然后我运行update-grub

amedee@kerbol:~/repos/ubuntu-impish$ sudo update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.13.0-22-generic
Found initrd image: /boot/initrd.img-5.13.0-22-generic
Found linux image: /boot/vmlinuz-5.13.0-22-generic
Found initrd image: /boot/initrd.img-5.13.0-22-generic
Adding boot menu entry for UEFI Firmware Settings
done

我的编译内核5.13.19-ubuntu-5.13.0-22.22没有通过 添加到 Grub 菜单中update-grub。我知道我可以手动添加它,但这样有输入错误的风险。我还需要编译很多内核,因为我正在尝试使用 来查找可能的错误git bisect。我正在排除故障的内核问题不会出现在较新的主线内核中,只会出现在(部分但不是全部)Ubuntu 21.10 内核中,所以我这样做只是为了学习一些东西并满足我的好奇心。

我需要做什么才能update-grub将我编译的内核从/boot目录添加到 Grub 菜单?

答案1

以下三个命令通过关闭 的可执行位09_lowlatency并打开 的位来解决此问题10_linux,符合 中的文字/etc/grub.d/README.lowlatency

# chmod -x /etc/grub.d/09_lowlatency
# chmod +x /etc/grub.d/10_linux
# update-grub

解决方案位于https://askubuntu.com/a/1228269/149519

为了确认它现在能按预期工作:

$ ls -hal /boot ; echo ; sudo update-grub
total 107M
drwxr-xr-x  4 root root 4,0K feb 28 04:42 .
drwxr-xr-x 20 root root 4,0K feb 26 01:13 ..
-rw-r--r--  1 root root 252K nov  5 10:21 config-5.13.0-22-generic
-rw-r--r--  1 root root 251K feb 26 02:15 config-5.13.19-ubuntu-5.13.0-22.22
drwx------  4 root root 4,0K jan  1  1970 efi
drwxr-xr-x  5 root root 4,0K feb 28 04:42 grub
lrwxrwxrwx  1 root root   28 feb 28 04:26 initrd.img -> initrd.img-5.13.0-22-generic
-rw-r--r--  1 root root  40M feb 26 13:55 initrd.img-5.13.0-22-generic
-rw-r--r--  1 root root  37M feb 26 13:54 initrd.img-5.13.19-ubuntu-5.13.0-22.22
-rw-------  1 root root 5,7M nov  5 10:21 System.map-5.13.0-22-generic
-rw-r--r--  1 root root 5,6M feb 26 02:15 System.map-5.13.19-ubuntu-5.13.0-22.22
lrwxrwxrwx  1 root root   25 feb 28 04:27 vmlinuz -> vmlinuz-5.13.0-22-generic
-rw-------  1 root root 9,8M nov  5 13:51 vmlinuz-5.13.0-22-generic
-rw-r--r--  1 root root 8,5M feb 26 02:15 vmlinuz-5.13.19-ubuntu-5.13.0-22.22

Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.13.19-ubuntu-5.13.0-22.22
Found initrd image: /boot/initrd.img-5.13.19-ubuntu-5.13.0-22.22
Found linux image: /boot/vmlinuz-5.13.0-22-generic
Found initrd image: /boot/initrd.img-5.13.0-22-generic
Adding boot menu entry for UEFI Firmware Settings
done

相关内容