update-grub2 找不到自定义内核

update-grub2 找不到自定义内核

我基于 5.4.18-xanmod10 内核编译了一个新内核。然后我安装了它:

sudo dpkg -i linux*5.4.18-xanmod10-custom*.deb

但安装后,没有找到它update-grub2

root@lenovo:~# ls /boot/
config-5.3.0-29-lowlatency           memtest86+.elf
config-5.4.18-xanmod10-custom        memtest86+_multiboot.bin
config-5.5.0-3.2-liquorix-amd64      System.map-5.3.0-29-lowlatency
config-5.5.0-4.1-liquorix-amd64      System.map-5.4.18-xanmod10-custom
config-5.5.4-xanmod3                 System.map-5.5.0-3.2-liquorix-amd64
grub                                 System.map-5.5.0-4.1-liquorix-amd64
initrd.img                           System.map-5.5.4-xanmod3
initrd.img-5.3.0-29-lowlatency       vmlinuz
initrd.img-5.4.18-xanmod10-custom    vmlinuz-5.3.0-29-lowlatency
initrd.img-5.5.0-3.2-liquorix-amd64  vmlinuz-5.4.18-xanmod10-custom
initrd.img-5.5.0-4.1-liquorix-amd64  vmlinuz-5.5.0-3.2-liquorix-amd64
initrd.img-5.5.4-xanmod3             vmlinuz-5.5.0-4.1-liquorix-amd64
initrd.img.old                       vmlinuz-5.5.4-xanmod3
memtest86+.bin                       vmlinuz.old

root@lenovo:~# 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.3.0-29-lowlatency
Found initrd image: /boot/initrd.img-5.3.0-29-lowlatency
Found linux image: /boot/vmlinuz-5.3.0-29-lowlatency
Found initrd image: /boot/initrd.img-5.3.0-29-lowlatency
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done

存在其他内核,但重启后lowlatencygrub 菜单中只显示 kernel 和 memtest。此外,在更新过程中,它会显示同一个内核两次。以前,在通用内核移动到另一个文件夹之前,grub 更新期间会列出通用内核和低延迟内核。

我该如何解决这个问题?

答案1

以下三个命令也解决了这个问题,方法是关闭 09_lowlatency 上的可执行位并打开 10_linux 上的可执行位,与 /etc/grub.d/README.lowlatency 中的文本一致。我建议在调用 update-grub 之前编辑 /etc/default/grub 以将 GRUB_TIMEOUT 更改为正值。

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

答案2

我已经解决了,但是解决方案不是很好。

  1. 将低延迟 grub 配置文件复制到新的自定义 grub 配置文件中:sudo cp /etc/grub.d/09_lowlatency /etc/grub.d/08_custom
    09_lowlatency通过以下方式获取文件指示

    首先,让我们访问https://packages.ubuntu.com/。这一步不太明显。软件包“ubuntustudio-default-settings”包含一个名为“09_lowlatency”的文件。该文件是一个 GRUB 配置文件,我们可以使用它来确保我们的 lowlatency 内核首先启动,并确保它将保持这种状态。

  2. 删除这些文件,这样它们就不会重复 grub 菜单条目,也不会在sudo update-grub2命令执行期间在列表中重复:
    sudo mv /etc/grub.d/10_linux /home/myuser/backup/ && sudo mv /etc/grub.d/09_lowlatency /home/myuser/backup/

  3. 我更改了文件case中的一个语句08_custom
    更改之前它是:

    case "x$machine" in
        xi?86 | xx86_64)
            list=
            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
            list2=
            for i in /boot/vmlinuz-*generic /vmlinuz-*generic /boot/kernel-*generic ; do
                if grub_file_is_not_garbage "$i" ; then list2="$list2 $i" ; fi
            done ;;
        *)
            list=
            for i in /boot/vmlinuz-*lowlatency /boot/vmlinux-*lowlatency /vmlinuz-*lowlatency /vmlinux-*lowlatency /boot/kernel-*lowlatency ; do
                      if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
            done
            list2=
            for i in /boot/vmlinuz-*generic /boot/vmlinux-*generic /vmlinuz-*generic /vmlinux-*generic /boot/kernel-*generic ; do
                      if grub_file_is_not_garbage "$i" ; then list2="$list2 $i" ; fi
            done ;;
    esac
    

    改完之后变成:

    case "x$machine" in
        xi?86 | xx86_64)
            list=
            for i in /boot/vmlinuz-*lowlatency ; do
                if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
            done
            for i in /boot/vmlinuz-*generic ; do
                if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
            done
            for i in /boot/vmlinuz-*xanmod10-custom ; do
                if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
            done ;;
        *)
            list=
            for i in /boot/vmlinuz-*lowlatency ; do
                      if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
            done
            for i in /boot/vmlinuz-*generic ; do
                      if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi
            done
            for i in /boot/vmlinuz-*xanmod10-custom ; do
                      if grub_file_is_not_garbage "$i" ; then list2="$list2 $i" ; fi
            done ;;
    esac
    

我的ls -alh /bootsudo update-grab2命令显示以下内容:

$ ls -alh /boot
total 275M
drwxr-xr-x  3 root root 4,0K feb 17 00:32 .
drwxr-xr-x 20 root root 4,0K feb 13 09:55 ..
-rw-r--r--  1 root root 231K jan 17 15:59 config-5.3.0-29-generic
-rw-r--r--  1 root root 231K jan 17 15:59 config-5.3.0-29-lowlatency
-rw-r--r--  1 root root 138K feb 16 03:54 config-5.4.18-xanmod10-custom
-rw-r--r--  1 root root 216K feb 15 19:56 config-5.5.0-4.1-liquorix-amd64
-rw-r--r--  1 root root 237K feb 15 16:06 config-5.5.4-xanmod3
drwxr-xr-x  4 root root 4,0K feb 17 00:28 grub
lrwxrwxrwx  1 root root   35 feb 16 09:06 initrd.img -> initrd.img-5.5.0-4.1-liquorix-amd64
-rw-r--r--  1 root root  46M feb 13 21:37 initrd.img-5.3.0-29-generic
-rw-r--r--  1 root root  46M feb 14 00:01 initrd.img-5.3.0-29-lowlatency
-rw-r--r--  1 root root  12M feb 16 08:36 initrd.img-5.4.18-xanmod10-custom
-rw-r--r--  1 root root  53M feb 16 09:07 initrd.img-5.5.0-4.1-liquorix-amd64
-rw-r--r--  1 root root  52M feb 17 00:32 initrd.img-5.5.4-xanmod3
lrwxrwxrwx  1 root root   30 feb 16 09:06 initrd.img.old -> initrd.img-5.3.0-29-lowlatency
-rw-r--r--  1 root root 179K jan 28  2016 memtest86+.bin
-rw-r--r--  1 root root 181K jan 28  2016 memtest86+.elf
-rw-r--r--  1 root root 181K jan 28  2016 memtest86+_multiboot.bin
-rw-------  1 root root 4,5M jan 17 15:59 System.map-5.3.0-29-generic
-rw-------  1 root root 4,5M jan 17 15:59 System.map-5.3.0-29-lowlatency
-rw-r--r--  1 root root 4,2M feb 16 03:54 System.map-5.4.18-xanmod10-custom
-rw-r--r--  1 root root 3,9M feb 15 19:56 System.map-5.5.0-4.1-liquorix-amd64
-rw-r--r--  1 root root 5,1M feb 15 16:06 System.map-5.5.4-xanmod3
lrwxrwxrwx  1 root root   32 feb 16 09:06 vmlinuz -> vmlinuz-5.5.0-4.1-liquorix-amd64
-rw-------  1 root root  11M jan 17 16:35 vmlinuz-5.3.0-29-generic
-rw-------  1 root root  11M jan 17 16:35 vmlinuz-5.3.0-29-lowlatency
-rw-r--r--  1 root root 6,6M feb 16 03:54 vmlinuz-5.4.18-xanmod10-custom
-rw-r--r--  1 root root 8,9M feb 15 19:56 vmlinuz-5.5.0-4.1-liquorix-amd64
-rw-r--r--  1 root root 7,2M feb 15 16:06 vmlinuz-5.5.4-xanmod3
lrwxrwxrwx  1 root root   27 feb 16 09:06 vmlinuz.old -> vmlinuz-5.3.0-29-lowlatency

$ 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.4.18-xanmod10-custom
Found initrd image: /boot/initrd.img-5.4.18-xanmod10-custom
Found linux image: /boot/vmlinuz-5.4.18-xanmod10-custom
Found initrd image: /boot/initrd.img-5.4.18-xanmod10-custom
Found linux image: /boot/vmlinuz-5.3.0-29-lowlatency
Found initrd image: /boot/initrd.img-5.3.0-29-lowlatency
Found linux image: /boot/vmlinuz-5.3.0-29-generic
Found initrd image: /boot/initrd.img-5.3.0-29-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done

我删除了我不需要的多余代码,然后复制粘贴了一for对内核循环lowlatency并在其中lowlatency进行了更改。xanmod10-custom

$ ls -alh /etc/grub.d/
total 136K
drwxr-xr-x   2 root root 4,0K feb 17 00:28 .
drwxr-xr-x 141 root root  12K feb 17 00:31 ..
-rwxr-xr-x   1 root root  11K feb 11 16:57 00_header
-rwxr-xr-x   1 root root 6,2K feb 11 16:57 05_debian_theme
-rwxr-xr-x   1 root root  16K feb 17 00:28 08_xanmod_custom
-rwxr-xr-x   1 root root  37K feb 11 16:57 10_linux_zfs
-rwxr-xr-x   1 root root  13K feb 11 16:57 20_linux_xen
-rwxr-xr-x   1 root root 2,0K feb 28  2016 20_memtest86+
-rwxr-xr-x   1 root root  12K feb 11 16:57 30_os-prober
-rwxr-xr-x   1 root root 1,4K feb 11 16:57 30_uefi-firmware
-rwxr-xr-x   1 root root  214 feb 11 16:57 40_custom

相关内容