You are not logged in.

#1 2025-01-16 01:52:21

joaocandre
Member
Registered: 2013-02-23
Posts: 166

systemd-boot ignoring EFI variable override

I have systemd-boot as the default bootloader in my windows-arch dual-boot setup, and want to be able to select the next boot by overriding the default configuration using the LoaderEntryDefault EFI variable, however, it doesn't seem to be working.
I have set 'LoaderEntryDefault' from Windows (for reference, using the UEFIv2 Powershell module) and can confirm it is defined from both Windows and, most notably, Archlinux:

 $ efivar --list | grep LoaderEntryDefault
4a67b082-0a4c-41cf-b6c7-440b29bb8c4f-LoaderEntryDefault
 $ efivar --name 4a67b082-0a4c-41cf-b6c7-440b29bb8c4f-LoaderEntryDefault
GUID: 4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
Name: "LoaderEntryDefault"
Attributes:
	Non-Volatile
	Boot Service Access
	Runtime Service Access
Value:
00000000  61 72 63 68 2e 63 6f 6e  66              |arch.conf      |

and its value 'arch.conf' is the Archlinux entry configured:

$ ls /boot/loader/entries
arch.conf

However, during boot, the windows option remains the default selection.
What could be causing this? Per systemd-boot documentation, the value of 'LoaderEntryDefault' should be NUL-terminated. Could that be the issue? Or is this specific variable not intended to me manually set (it wasn't set by default)?
I've yet to try using 'LoaderEntryOneShot' as an alternative.

Offline

#2 2025-01-16 10:46:00

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 23,901

Re: systemd-boot ignoring EFI variable override

You can set that within systemd-boot itself by pressing d on a given entry.

Offline

#3 2025-01-16 17:09:51

joaocandre
Member
Registered: 2013-02-23
Posts: 166

Re: systemd-boot ignoring EFI variable override

I'm aware of that, but I want to update the variable from both OSs so that I don't need to wait for the boot menu during boot.

Offline

#4 2025-01-16 17:40:09

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 23,901

Re: systemd-boot ignoring EFI variable override

I could also see that you don't need the .conf suffix, did you look at the variable after setting it with systemd-boot to see what it's actual value is?

Offline

#5 2025-01-17 00:31:20

joaocandre
Member
Registered: 2013-02-23
Posts: 166

Re: systemd-boot ignoring EFI variable override

I did try with and without the '.conf' extension, made no difference. But I suspect the issue may in how the value of the variable is formatted (whether it's just the null-termination part or something else)

Following you suggestion, selecting Archlinux as the default entry on the boot menu led to the variable being set as

GUID: 4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
Name: "LoaderEntryDefault"
Attributes:
	Non-Volatile
	Boot Service Access
	Runtime Service Access
Value:
00000000  61 00 72 00 63 00 68 00  2e 00 63 00 6f 00 6e 00  |a.r.c.h...c.o.n.|
00000010  66 00 00 00                                       |f...            |

EDIT: I've tried with both entries and indeed seems line a null character is placed after each non-character, so that may definitely be reason why an unformated/simple string is being ignored.

Last edited by joaocandre (2025-01-17 02:16:14)

Offline

#6 2025-01-19 18:07:54

joaocandre
Member
Registered: 2013-02-23
Posts: 166

Re: systemd-boot ignoring EFI variable override

I've written a simple bash script that sets 'LoaderEntryDefault' or 'LoaderEntryOneShot', but it doesn't seem to work.
Notably, 'bootctl' seems to properly recognize the values of the EFI variables, listing

...
OneShot Entry: auto-windows
...

but it's ultimately ignored when rebooting (and 'LoaderEntryOneShot' is never cleared).
I'm unsure if this due to how the variable is formatted (strange, because 'auto-windows' works if I set it on the OS configuration in /boot/loader/loader.conf, and is one of the entries stored in the 'LoaderEntries' variable), or if there is something else happening here.

Offline

Board footer

Powered by FluxBB