I've got an unusual situation with a rented dedicated server. The provider uses PXE boot to provide the ability to rescue and repair machines, but if no rescue is needed then the PXE boot loads rEFInd and it then mounts the ESP and boots the system normally. This works fine, I have Debian 11 booting successfully using sd-boot this way.
The problem is that I've got an ESP on each of the two disks in the system, for redundancy, and I keep their contents updated when changes are made. In order to do that I need to mount the current ESP at /efi. On a system which doesn't use this weird double-boot mechanism this works fine, since efibootmgr will tell me which EFI boot entry was used to boot the system.
When this double-boot mechanism is in place, efibootmgr reports that the EFI boot entry for PXEboot was used... because it was :-)
Is there any way, from a running Linux system that was booted by rEFInd, to find out which ESP rEFInd used to find the boot loader and boot the system?
Last edit: Kevin P. Fleming 2022-11-25
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There's no direct way to do this; however, there is an indirect and hackish way to do it: Enable logging in rEFInd (on both ESPs) and then check the date stamps on the refind.log files in each ESP's EFI\refind directory. Whichever one has the more recent date stamp is the one that last ran.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Actually, I think there is a more direct way to do this: Since version 0.13.1, setting the write_systemd_vars token to true in refind.conf causes rEFInd to write the partition GUID of the ESP from which rEFInd launched to the LoaderDevicePartUUID EFI variable, which is accessible in /sys/firmware/efi/efivars in Linux. Note that the value is the partition's GUID (aka the PARTUUID in Linux), not the filesystem's UUID (aka the UUID in Linux).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've got an unusual situation with a rented dedicated server. The provider uses PXE boot to provide the ability to rescue and repair machines, but if no rescue is needed then the PXE boot loads rEFInd and it then mounts the ESP and boots the system normally. This works fine, I have Debian 11 booting successfully using sd-boot this way.
The problem is that I've got an ESP on each of the two disks in the system, for redundancy, and I keep their contents updated when changes are made. In order to do that I need to mount the current ESP at
/efi
. On a system which doesn't use this weird double-boot mechanism this works fine, sinceefibootmgr
will tell me which EFI boot entry was used to boot the system.When this double-boot mechanism is in place,
efibootmgr
reports that the EFI boot entry for PXEboot was used... because it was :-)Is there any way, from a running Linux system that was booted by rEFInd, to find out which ESP rEFInd used to find the boot loader and boot the system?
Last edit: Kevin P. Fleming 2022-11-25
There's no direct way to do this; however, there is an indirect and hackish way to do it: Enable logging in rEFInd (on both ESPs) and then check the date stamps on the
refind.log
files in each ESP'sEFI\refind
directory. Whichever one has the more recent date stamp is the one that last ran.Actually, I think there is a more direct way to do this: Since version 0.13.1, setting the
write_systemd_vars
token totrue
inrefind.conf
causes rEFInd to write the partition GUID of the ESP from which rEFInd launched to theLoaderDevicePartUUID
EFI variable, which is accessible in/sys/firmware/efi/efivars
in Linux. Note that the value is the partition's GUID (aka thePARTUUID
in Linux), not the filesystem's UUID (aka theUUID
in Linux).Thank you so much! It appears that this is already set on my system and this gives me the information that I need.