[SOLVED] Cannot install PVE as UEFI OS

I have an Intel NUC DN2820FYKH with an Intel Visual BIOS v2.2.5 and the same error installing Proxmox v8 or v9:
- failed to prepare EFI boot using Grub on '/dev/sda2': unable to install the EFI boot loader on '/dev/sda'
Tried a Kingston & Intel SSD HDD and the same behavior.
I could finally successful install Proxmox disabling the UEFI Boot in the BIOS and only enabling the Legacy Boot.
Afterwards it could not boot, no valid boot device was detected, and enabling both UEFI & Legacy Boots it worked fine.
 
I had the same error installing Proxmox on a Lenovo ThinkCentre M70s Gen 4 with the latest BIOS:


failed to prepare EFI boot using Grub ... unable to install the EFI boot loader


and during installation:


Cannot set EFI variable
efivarfs_set_variable: ... Cannot allocate memory


I found that the problem was a Lenovo BIOS setting.


In BIOS go to Security and set:


Windows UEFI Firmware Update → Disabled


I already had Secure Boot disabled.


After disabling Windows UEFI Firmware Update, I performed a normal Proxmox installation again and it completed successfully. No GRUB workaround, fallback BOOTX64.EFI, EFI-variable deletion, or rescue boot was required.


Hardware: Lenovo ThinkCentre M70s Gen 4


Hopefully this helps anyone with the same issue on recent Lenovo ThinkCentre systems.
 
Well, the thread is solved, but nothing helped me so far from here, neither from another thread, so LMTry and sum it up nicely what I had to do.

Mr. LLM model tells me it's a UEFI firmware bug which i can neither deny or confirm, but it's, well, sad...
For the sake, I'm using a Lenovo Thinkcentre M70q Gen.5 with freshest avail BIOS framework (26 Jun 2025).

Anyways, let's not waste time here:
1. Install proxmox from a bootable device (like USB, via Rufus)
2. Get the error message of failed to prepare EFI boot using Grub on '/dev/sda2': unable to install the EFI boot loader on '/dev/sda'
3. Reboot
4. Select Advanced from the USB's installation boot-menu => Rescue boot
4.1. It should let in with the root and the pw you set.
5. Copy a fallback bootloader: cp /boot/efi/EFI/proxmox/grubx64.efi /boot/efi/EFI/BOOT/BOOTX64.EFI
6. That wasn't enough so I had to copy the whole config folder alongside: cp -r /boot/grub/x86_64-efi /boot/efi/EFI/BOOT/
7. Let grub to re-configure bootloader: grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=proxmox --removable --recheck
7.1. It might happen grub-install does have difficulties or wrongly installed, therefore it needs (needed in my case) re-install, so find online how to...
8. Apply the config change: update-grub

Voila! It must work, if you had the same reason as I.

FINAL NOTE: I'd hope I left out nothing, because I really spent hours trying to debug and fix, while did a lod of re-installs and operations in the meantime. I'll likely need a re-install soon, therefore will update if so.
I have a white box type physical device I have been using or pfSense, and was looking forward to reuse it for Proxmox. Had same issue. This article worked like a charm. Thanks @pvemexer.