Installed Debian bookworm in a VM… Grub is installed on the disk image.
However, the VM boots into UEFI shell every time. If I exit the shell and go into the Boot Maintenance Manager, delete existing (wrong!) entries, and then add the correct grubx64.efi option, it doesn’t save it for next reboot, even though I hit F10, and it goes into UEFI shell again when I reboot the VM. It clearly fails to retain the UEFI boot options.
Fix?
From the info you’ve provided, I have to ask whether you deleted the install CD image from the device list of the truenas VM.
Yes, I deleted the CDROM device. VM boots to EFI shell everytime, no matter what I do in the Boot Maintenance Manager. Likewise I tried modifying EFI configuration using efibootmgr in Linux, the Debian install should be the only option because I deleted everything else, yet after reboot it’s UEFI shell again, and if I exit and look into Boot Manager all the deleted options are back again and my correct option is gone.
This is a hairpulling problem, but I came up with a rusty coathanger workaround for the moment. I copied grub.cfg from the hard disk and modified the Debian installation ISO replacing the grub.cfg in the ISO, so the ISO boots the operating system on the hard disk instead. That’s the only way I can make this UEFI play ball.
Well, you know Bookworm recently did an update to its grub because MSFT had a Win 11 update to Secure Boot that broke dual boot PCs. It happened to my dual boot LMDE install and for awhile I had to disable Secure Boot but then Debian updated its grub and I’ve been able to use Secure Boot again. Anyway, happy for your workaround, personally I run Ubuntu server with Docker in my truenas VM and SSH in.
It’s actually Bullseye, but that’s not even important, and has zilch to do with secure boot and everything to do with a buggy virtual host.
No, I don’t consider that workaround “acceptable”, but I might have to live with it, as there are other known defects in my TrueNAS release that I will just have to swallow as well.