Comment 5 for bug 1862846

Revision history for this message
Ryan Harper (raharper) wrote :

OK, I think I've found the bug; there are two issues;

if [ "${#grubdevs_new[@]}" -eq 1 ] && [ -f "${grubdevs_new[0]}" ]; then
    # Currently UEFI can only be pointed to one system partition. If
    # for some reason multiple install locations are given only use the
    # first.
    efi_dev="${grubdevs_new[0]}"
elif [ "${#grubdevs_new[@]}" -gt 1 ]; then
    error "Only one grub device supported on UEFI!"
    exit 1
else
    # If no storage configuration was given try to determine the system
    # partition.
    efi_dev=$(awk -v "MP=${mp}/boot/efi" '$2 == MP { print $1 }' /proc/mounts)
fi

The [ -f "${grubdevs_new[0]}" ] is checking if the target disk/partition is a file.
This fails as they are block devices; the check should be [ -b "${grubdevs_new[0]}" ].

Because this fails, we fall into the else clause, which is able to figure out from
/proc/mounts that the efi_dev is /dev/sda1.

Now, further down when we convert the efi_dev into the disk and partition we run this code

        # The partition number of block device name need to be determined here
        # so both getting the UEFI device from Curtin config and discovering it
        # work.
        efi_part_num=$(cat /sys/class/block/$(basename $efi_dev)/partition)
        efi_disk="/dev/$(lsblk -no pkname $efi_dev)"

lsblk -no pkname $efi_dev

returns an empty string; that's because 'pkname' is an unknown column in lsblk,
rather the value should be 'kname'. This error results in efi_disk being set to "/dev/"

This isn't found on non-shim based installs as efi_disk variable is not used unless we are creating our own efibootmgr entry.