grub-efi-amd64 postinst fails to install GRUB if /boot/efi/EFI/ubuntu/ is not present

Bug #1783044 reported by Daniel Richard G.
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
Triaged
Medium
Unassigned

Bug Description

This concerns grub-efi-amd64 2.02-2ubuntu8.1 in Ubuntu 18.04/bionic.

When the grub-efi-amd64 package is initially installed on a system that has not previously booted via the Ubuntu EFI bootloader (so /boot/efi/ is either empty, or at least does not have a /boot/efi/EFI/ubuntu/ directory), the package postinst script fails to install anything into /boot/efi/.

The postinst script, in fact, contains this conditional around the grub-install invocation:

    if [ "$bootloader_id" ] && [ -d "/boot/efi/EFI/$bootloader_id" ]; then

It's not clear why this is here. There might be a reason why you would not want to install/update the bootloader if the directory for it isn't already there. In my case, however, I am running the postinst script (via dpkg-reconfigure) precisely to populate an EFI partition from scratch.

I can work around this issue with a simple

    # mkdir -p /boot/efi/EFI/ubuntu

before running dpkg-reconfigure, but this is far from obvious.

An additional problem with the conditional is that if it fails, no message is given to the user that the postinst is omitting the GRUB install, let alone the reason why. If the user misses the absence of the grub-install message, they'll only find out something went wrong when they attempt to boot using the newly-installed bootloader and it doesn't work.

Revision history for this message
Daniel Richard G. (skunk) wrote :

I should point out that on the Debian side, the same conditional exists in the postinst script, so this same issue occurs there as well. (Only with the /boot/efi/EFI/debian/ directory, of course.)

Revision history for this message
Simon Quigley (tsimonq2) wrote :

From what I have learned switching Lubuntu to Calamares, Ubiquity is what does this. If it isn't an EFI system, it doesn't do this verification.

So, I agree with this being a grub2 bug.

I'll take a shot at fixing this; it shouldn't be terribly difficult.

Changed in grub2 (Ubuntu):
assignee: nobody → Simon Quigley (tsimonq2)
status: New → Won't Fix
status: Won't Fix → Confirmed
importance: Undecided → Medium
Revision history for this message
Phillip Susi (psusi) wrote :

I would think that the postinst script should use a low priority debconf question to ask if you want to create the directory and install or not, and default to not if you aren't showing low priority questions.

Revision history for this message
Daniel Richard G. (skunk) wrote :

Philip, wouldn't such a debconf question be closely related to the existing question on whether to install to the EFI removable media path?

Because if you're not putting things into EFI/ubuntu/ (or EFI/debian/), then you'd be putting them into EFI/BOOT/ ...

Revision history for this message
Phillip Susi (psusi) wrote :

No; you may not be installing it anywhere at all. It is perfectly valid to have the grub-efi package installed in a PC that is booting in bios mode ( in fact, apparently we do now install both grub-efi and grub-pc if you boot the installer in EFI mode but the existing OS installed is in bios mode ). You don't want every update of the package to try and fail to reinstall in that case.

Revision history for this message
Daniel Richard G. (skunk) wrote :

My understanding is that grub-pc conflicts with grub-efi-amd64 (and other top-level GRUB packages), so having both installed shouldn't even be possible. (I've filed a bug report on the Debian side to address this, as this situation is not ideal: https://bugs.debian.org/904062) And that if you want the GRUB installation tools, but don't want the bootloader installed automatically on the running system, then this is when you'd install a grub-foo-bin package without the corresponding grub-foo.

My point was just that the "Don't install to the EFI removable media path" question is not orthogonal to your hypothetical "Create an EFI subdirectory?" question, so maybe the solution would be to replace the former with some kind of multi-choice question.

Revision history for this message
Phillip Susi (psusi) wrote :

Ahh, I forgot about the -bin. I was talking to sil2000 on IRC the other day and he said he has made cosmic install them both, but they do still appear to conflict. Strange.

Revision history for this message
Daniel Richard G. (skunk) wrote :

I think there's a good case to get rid of those Conflicts:, at least for the package combinations that make sense. BIOS+EFI definitely makes sense, IMO.

Simon Quigley (tsimonq2)
Changed in grub2 (Ubuntu):
assignee: Simon Quigley (tsimonq2) → nobody
Changed in grub2 (Ubuntu):
status: Confirmed → Triaged
Revision history for this message
Daniel Richard G. (skunk) wrote :

I've confirmed that, as of focal, the /boot/efi/EFI/ubuntu/ directory no longer needs to be present in order for the grub-efi-amd64 package to install the bootloader files. Even /boot/efi/EFI/ does not need to be there; it will be created. This issue still appears to exist on the Debian side, however, and Ubuntu now has a related problem (LP: #1879558).

Should I file a new bug regarding a concurrent grub-pc + grub-efi-amd64 installation? Is that something that could be reasonably supported?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.