我在 Hyper-V 上以第二代 (UEFI) VM 的形式运行 Ubuntu 20.04.2。今天我想做一个apt upgrade
之前grub-efi-amd64 (2.04-1ubuntu26.9)
更新grub-efi-amd64 (2.04-1ubuntu26.7)
过程停止在
Installing grub to /var/lib/grub/esp.
Installing for x86_64-efi platform.
grub-install: error: /var/lib/grub/esp doesn't look like an EFI partition.
仅当虚拟机有多个虚拟硬盘时才会出现此错误。我该怎么做才能/var/lib/grub/esp
不使用而只使用/boot/efi
?
我只有一个启动分区!
sudo apt --reinstall install grub-efi-amd64
使用一个虚拟硬盘就可以重现这个问题,一切正常:
Installing grub to /boot/efi.
Installing for x86_64-efi platform.
答案1
看起来,当你有两个驱动器时,错误的驱动器会被安装为具有 EFI 分区的驱动器。解决这个问题取决于你对在操作不当的情况下丢失数据的承受能力,但基本上我会做的是找出哪个分区有 EFI 特殊分区(通过运行sudo fdisk -l
并找出类似于
Device Start End Sectors Size Type
/dev/sdaX 2048 1050623 1048576 512M EFI System
/dev/sdaY 1050624 500117503 499066880 238G Linux filesystem
这意味着 /dev/sdaX 是我们想要挂载在 /var/lib/grub/esp 中的分区
然后在升级之前,我会尝试在 /var/lib/grub/esp 中手动将其安装为 FAT32
喜欢sudo mount.vfat /dev/sdaX /var/lib/grub/esp
然后重试升级。
当然,所有这些都容易导致数据丢失。这意味着如果你操作失误,你可能无法启动
答案2
非常感谢您的快速回复。
我忘了更新过程还在继续:
后grub-install: error: /var/lib/grub/esp doesn't look like an EFI partition.
问题是:
GRUB failed to install to the following devices:
/dev/sdb1
Do you want to continue anyway? If you do, your computer may not start up properly.
Writing GRUB to boot device failed - continue?
如果我说“不”:
Installing grub to /boot/efi.
Installing for x86_64-efi platform.
Installation finished. No error reported.
Installing grub to /var/lib/grub/esp.
Installing for x86_64-efi platform.
grub-install: error: /var/lib/grub/esp doesn't look like an EFI partition.
然后又出现了同样的问题。如果我说是:
Installing grub to /boot/efi.
Installing for x86_64-efi platform.
Installation finished. No error reported.
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.0-1043-azure
Found initrd image: /boot/initrd.img-5.4.0-1043-azure
Found linux image: /boot/vmlinuz-5.4.0-1041-azure
Found initrd image: /boot/initrd.img-5.4.0-1041-azure
Found linux image: /boot/vmlinuz-5.4.0-70-generic
Found initrd image: /boot/initrd.img-5.4.0-70-generic
Adding boot menu entry for UEFI Firmware Settings
done
Processing triggers for shim-signed (1.40.4+15+1552672080.a4a1fbe-0ubuntu2) ...
user@ubuntu:~$
如何防止 grub 安装在第二个虚拟磁盘上