Subject: bug#47889: [installer image] grub-install efi fails getting canonical path to /boot/efi on dos-formatted disk

From: Mathieu Othacehe <[email-masked]>
Date: Sun, 25 Apr 2021 16:15:56 +0200

Hello,

> I’m not entirely sure how it decides between GPT and DOS, though;
> Mathieu?
>
> We should add UEFI installation tests using OVMF.

I could reproduce this issue with the following steps:

--8<---------------cut here---------------start------------->8---
qemu-img create -f qcow2 guix-system.img 50G
qemu-system-x86_64 -m 1024 -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin -cdrom /gnu/store/<lastest-image.iso> -hda guix-system.img
Choose the msdos disk type in the auto-partitioning installer partitioning menu.
--8<---------------cut here---------------end--------------->8---

When using the auto-partitioning, the installer probes the selected
installation device type. If it has no type, like with my reproducer, it
asks whether to use msdos or gpt.

If the disk is already using an msdos or gpt layout, it is preserved.

Then, the auto-partitioning considers erroneously that ESP partitions
are not supported on msdos disks with the following code snippet:

--8<---------------cut here---------------start------------->8---
(and (not has-extended?) ;not msdos?
                 (if (efi-installation?)
                     (and (not esp-partition)
                          (user-partition
                           (fs-type 'fat32)
                           (esp? #t)
                           (size new-esp-size)
                           (mount-point (default-esp-mount-point))))
                     (user-partition
                      (fs-type 'ext4)
                      (bootable? #t)
                      (bios-grub? #t)
                      (size bios-grub-size))))
--8<---------------cut here---------------end--------------->8---

Finally, grub-efi fails because there's no /boot/efi mount point.

This problem can then occur for two reasons:

1. The user is booting the installation image with UEFI support, using
  an empty installation device, choosing auto-partition and msdos as
  disk type.

2. The user is booting the installation image with UEFI support, using
  an already msdos formatted installation device and choosing
  auto-partition.

I think we could solve 1. easily, by forcing the GPT layout. Solving
2. is a bit trickier.

As Ludo suggested, we also need to create new installer tests covering
UEFI installations.

I'll try to come up with a patch soon.

Thanks,

Mathieu