0

I have an Ubuntu 20.04.2 running as a Generation 2 (UEFI) VM on a Hyper-V. Today I wanted to do an apt upgrade with grub-efi-amd64 (2.04-1ubuntu26.9) previously grub-efi-amd64 (2.04-1ubuntu26.7) The update process stops at

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.

This error only occurs if the VM has more than one virtual hard disk. What can I do so that /var/lib/grub/esp is not used but only /boot/efi?

I have only one boot partition!

The problem can be reproduced with sudo apt --reinstall install grub-efi-amd64 With one virtual hard disk it is all ok:

Installing grub to /boot/efi.
Installing for x86_64-efi platform.
0

Looks like when you have two drives, the wrong one gets mounted as the drive that has the EFI partition. Solving this depends on how comfortable you're with loosing data in case of bad manipulation, but basically what I'd do is to figure out what partition has the EFI Special Partition (by running sudo fdisk -l and finding out the line that would look something like

Device       Start       End   Sectors  Size Type
/dev/sdaX     2048   1050623   1048576  512M EFI System
/dev/sdaY  1050624 500117503 499066880  238G Linux filesystem

this means that /dev/sdaX is the partition we want to be mounted in /var/lib/grub/esp

then before doing the upgrade I'd try to manually mount it as FAT32 in /var/lib/grub/esp

like sudo mount.vfat /dev/sdaX /var/lib/grub/esp and then retry the upgrade.

All of this of course is data-loss prone. Mean that possibly you won't be able to boot if you miss-manipulate

0

Many thanks for the quick response.

I forgot that the update process continues:

After grub-install: error: /var/lib/grub/esp doesn't look like an EFI partition.

Comes this question:

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?  

If i say No:

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.

Then comes the same question again. If i say Yes:

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:~$ 

How can I prevent grub from being installed on the 2nd virtual disk

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.