为什么在运行“apt upgrade”后会出现“警告:os-prober将不会执行以检测其他可引导分区。”的提示?

我正在使用Ubuntu 22.04,一切都很好。今天我运行了sudo apt update && sudo apt upgrade命令,最后出现了以下警告:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.0-39-generic
Found initrd image: /boot/initrd.img-5.15.0-39-generic
Found linux image: /boot/vmlinuz-5.15.0-37-generic
Found initrd image: /boot/initrd.img-5.15.0-37-generic
Memtest86+ needs a 16-bit boot, that is not available on EFI, exiting
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done

从我所看到的情况来看,当同一台机器上安装了多个操作系统时,会使用os-prober,那么为什么会出现这个警告呢?我只安装了Ubuntu 22.04。是因为找到了两个内核吗?
关于os-prober的问题,已经在评论中解决了Memtest86+,但是os-prober呢?
这是/etc/default/grub的内容:
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

Memtest86+是一个内存测试程序,它从Grub菜单启动,但是该程序无法在您的硬件上运行,因此在您的系统上被忽略。您几乎无法做任何事情,在某些机器上它是可执行的,但是相同的代码在其他机器上却不是;如果您的硬件能够运行Ubuntu提供的版本,菜单项将显示(它没有为Secure-uEFI签名,因此在许多现代设备上无法引导)。 - guiverc
3这个回答解决了你的问题吗?如果我使用UEFI,我可以启动memtest86+吗? - guiverc
2这篇文章解释了为什么以及如何修复memtest86+部分的问题。但是我还需要知道如何处理os-prober警告。我知道它说如果我将GRUB_DISABLE_OS_PROBER切换为False,警告就会消失。但由于我没有安装其他操作系统,这个警告本不应该出现,因为它是默认选项。 - vmisq
文件/etc/grub.d/30_os-prober是否可执行?请使用ls -l /etc/grub.d/30_os-prober进行检查。 - mook765
是的:-rwxr-xr-x - vmisq
1个回答

警告是由/etc/grub.d/30_os-prober生成的,请查看43至59行:
if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
  grub_warn "$(gettext_printf "os-prober will not be executed to detect other bootable partitions.\nSystems on them will not be added to the GRUB boot configuration.\nCheck GRUB_DISABLE_OS_PROBER documentation entry.")"
  exit 0
elif [ "x${GRUB_DISABLE_OS_PROBER}" = "xauto" ]; then
  # UBUNTU: We do not want to disable os-prober on upgrades if we found items before.
  if test -e /boot/grub/grub.cfg && ! grep -q osprober /boot/grub/grub.cfg; then
    grub_warn "$(gettext_printf "os-prober will not be executed to detect other bootable partitions.\nSystems on them will not be added to the GRUB boot configuration.\nCheck GRUB_DISABLE_OS_PROBER documentation entry.")"
    exit 0
  fi
fi

if ! command -v os-prober > /dev/null || ! command -v linux-boot-prober > /dev/null ; then
  # missing os-prober and/or linux-boot-prober
  exit 0
fi

grub_warn "$(gettext_printf "os-prober will be executed to detect other bootable partitions.\nIts output will be used to detect bootable binaries on them and create new boot entries.")"

你有几个选择:
  • 忽略警告,它只是一个警告,不是错误。

  • /etc/default/grub中设置变量GRUB_DISABLE_OS_PROBER=false。警告将会改变为“os-prober 将被执行以检测...”,正如我们可以在脚本片段中看到的那样。

  • /etc/grub.d/30_os-prober中删除可执行权限。这将阻止脚本的执行,因此您将无法收到任何这些警告。您可以使用以下命令进行操作:

    sudo chmod -x /etc/grub.d/30_os-prober
  • 编辑脚本/etc/grub.d/30_os-prober。如果您注释掉带有grub_warn的行,脚本将在不发出这些警告的情况下运行。


1тЈдСИђСИфжђЅТІЕТў»ТЅДУАїapt purge os-proberсђѓ - Larsen
@Larsen 这确实会删除/usr/bin/os-prober,但不会删除作为grub-common软件包的一部分的脚本/etc/grub.d/30_os-prober,因此当运行update-grub时,您仍然会收到其中一个警告。您尝试过您的建议吗? - mook765
1是的,而且它有效。脚本包含了一个检查缺少 os-prober 和/或 linux-boot-prober的部分,然后退出。 - Larsen

  • 相关问题