I am putting together a new Debian system with a few peculiarities:
I am not using the standard installer, but doing it by hand using debootstrap. Reason: my underlying disks (1 SSD and 2 large hard disks) have certain requirements not covered in any of the standard installers. I have bcache for one of the HDs (backing partition) mapped on to one of the partitions on the SSD (cache). On top of that, I have multiple luks encrypted partitions (including an encrypted /boot), and then multiple LVMs. This choice is specific to certain applications I am going to use the machine for. After a lot of trial and error, and consulting numerous online resources, I have got this installed the way I want, and I can mount partitions, and chroot into the system. I have set up a user, and packages I need etc.
The problem I have run into is EFI and grub. The system doesn't boot (No bootable devices found, even before getting to the grub screen - so the problem is with EFI). Yes, I used efi=runtime kernel option in the live USB boot, confirmed that /sys/firmware/efi/efivars was non empty, and efibootmgr reports that the EFI entry for the system exists. I did mount /sys/firmware/efi/efivars prior to chroot, update -u -k all, grub-install /dev/sda and update-grub. Just to be safe, I deleted all the EFI entries (except the live USB) prior to grub-install. I have secure boot disabled in the BIOS. There used to be an old working Linux installation on this machine, so I know that the BIOS doesn't have any anti-Linux quirks.
I have been extra careful with UUIDs, which led me to notice something strange:
The UUID generated inside chroot by the above commands in /boot/efi/debian.. grub.cfg doesn't correspond to any of the many UUIDs present on the system (yes, I have checked and rechecked). Certainly not to /dev/sdc1 which is the block device housing the encrypted /boot, and certainly not to the luks container that is mapped to /boot. /boot/efi is the only unencrypted partition in my setup.
I have thought of manually editing grub.cfg in EFI, but held back just in case this is expected behavior.
A few more pieces of possibly relevant information. This system has /boot/efi on /dev/sda1 (unencrypted), and /dev/mapper/EncryptedBootPartition on /dev/sdd1 (/dev/sdb is taken up by an external USB disk (no, it is not used for the install), while /dev/sdc1 is the backing partition, with cache on /dev/sda2). The /boot partition is outside any of the LVM groups, so there is no LVM involvement for /boot. Given that there is an external USB disk present, I am using UUIDs for everything in /etc/fstab and /etc/crypttab. The last thing doesn't matter for this problem anyways since I am unable to get past EFI.
There used to be an old Linux installation on one of the disks, but all the disks have been through an ATA secure clean and multiple reformats during this setup, so I can't imagine how an old stale UUID would get into this new system.
Why would grub-install generate a bogus UUID? What should I do to fix this? I would prefer a scriptable solution because once this setup is proven to result in a working system, I plan to distribute the long bash script I have written to accomplish all of the above.