AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1210882
Accepted
Gryu
Gryu
Asked: 2020-02-17 04:13:14 +0800 CST2020-02-17 04:13:14 +0800 CST 2020-02-17 04:13:14 +0800 CST

update-grub2 找不到自定义内核

  • 772

我已经编译了一个基于 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

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

我该如何解决这个问题?

grub2 kernel 19.10
  • 2 2 个回答
  • 734 Views

2 个回答

  • Voted
  1. Best Answer
    Bret Lyons
    2020-04-19T07:09:25+08:002020-04-19T07:09:25+08:00

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

    # chmod -x /etc/grub.d/09_lowlatency
    # chmod +x /etc/grub.d/10_linux
    # update-grub
    
    • 4
  2. Gryu
    2020-02-17T11:49:38+08:002020-02-17T11:49:38+08:00

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

    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 配置文件,我们可以使用它来确保我们的低延迟内核首先启动并确保它保持这种状态。

    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 /boot和sudo 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循环并更​​改为其中。lowlatencylowlatencyxanmod10-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
    
    • 0

相关问题

  • 与 Grub 相比,使用 Grub2 有什么好处?

  • 如果旧版 grub 安装在引导分区扇区而不是 MBR 中,如何将 grub 更新为 grub2?

  • Ubuntu 是否支持与 SSD 一起使用的 TRIM 命令?

  • 如何在 Ubuntu 启动时显示或隐藏启动消息?

  • 使用 apt-get upgrade 时如何强制安装内核更新?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve