grub-install 错误。无法注册 EFI 启动项:操作不允许。mount:/var/lib/grub/esp:挂载点不存在

grub-install 错误。无法注册 EFI 启动项:操作不允许。mount:/var/lib/grub/esp:挂载点不存在

grub-install 重新安装 grub 失败:

Installing for x86_64-efi platform.
grub-install: warning: Internal error.
grub-install: error: failed to register the EFI boot entry: Operation not permitted.

我在执行升级时注意到,尝试升级软件包 grub-efi-amd64-signed。这给出了一个更具信息性的错误消息:

Installing grub to /boot/efi.
Installing for x86_64-efi platform.
grub-install: warning: Internal error.
grub-install: error: failed to register the EFI boot entry: Operation not permitted.
mount: /var/lib/grub/esp: mount point does not exist.

系统正在尝试在 /var/lib/grub/esp 上查找 EFI 分区

这很奇怪,因为我的 fstab 看起来正确,

/dev/sda7 有 boot 标志,/dev/sda2 有 esp 标志。我不知道为什么 grub-install 会转到 /var/lib 来尝试查找 efi 分区。即使我明确将目录传递给 grub-install,错误仍然存​​在。

grub-install --efi-directory=/boot/efi/ --boot-directory=/boot/

我尝试运行启动修复,但并没有解决问题。

答案1

同样的错18.04.6 LTS (GNU/Linux 4.15.0-147-generic x86_64)

我的解决方案是替换--auto-nvram为调用的--no-nvram位置grub-install(如建议的那样这里这里)。

vim /var/lib/dpkg/info/grub-efi-amd64-signed.postinst
vim /var/lib/dpkg/info/shim-signed.postinst

然后再次运行,apt upgrade没有错误。

答案2

关闭快速启动 UEFI 设置后,grub-install 问题消失。我还按照 @oldfred 的建议从 Windows 本身关闭了快速启动。grub-install有效。但是,当我升级 grub-efi-amd64-signed 包时,我仍然收到相同的 /var/lib/grub/esp 错误:

Setting up grub-efi-amd64-signed (1.142.9+2.04-1ubuntu26.7) ...
Installing grub to /boot/efi.
Installing for x86_64-efi platform.
Installation finished. No error reported.
mount: /var/lib/grub/esp: mount point does not exist.
dpkg: error processing package grub-efi-amd64-signed (--configure):
 installed grub-efi-amd64-signed package post-installation script subprocess returned error exit status 32
Errors were encountered while processing:
 grub-efi-amd64-signed

之后,通过运行以下命令清除 grub 并重新安装 grub 解决了grub-efi-amd64-signed安装问题。

sudo apt-get purge grub\*
sudo apt-get install grub-efi
sudo apt-get autoremove
sudo update-grub

相关内容