Menu

Determine which ESP was used to boot system?

2022-11-25
2023-02-19
  • Kevin P. Fleming

    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
  • Roderick W. Smith

    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.

     
  • Roderick W. Smith

    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).

     
  • Kevin P. Fleming

    Thank you so much! It appears that this is already set on my system and this gives me the information that I need.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.