Answer the question
In order to leave comments, you need to log in
How to create a UEFI variable and write a string value to it in Linux?
The computer has Gentoo Linux and Windows installed in dual-boot.
Systems boot in EFI mode. The default bootloader is systemd-boot, which in turn boots Gentoo Linux by default after a timeout.
There is a goal to make it possible to reboot immediately in Windows without having to change the selection in systemd-boot.
As far as I understand from the documentation , this can be done using a variable LoaderEntryOneShot
. But I have not succeeded in
writing down the value auto-windows
( automatically detected by Windows Boot Manager).
What I tried:
# здесь и далее UUID сгенерирован рандомно с помощью uuidgen
# в файле /tmp/efivar-auto-windows лежит значение, которое я хотел записать в переменную
efivar -w -n 926b68c6-77da-4cf6-ba58-2f27df0f705d-LoaderEntryOneShot -f /tmp/efivar-auto-windows
# efivar: Input/output error
echo "auto-windows" > /sys/firmware/efi/efivars/LoaderEntryOneShot-926b68c6-77da-4cf6-ba58-2f27df0f705d
# echo: write error: invalid argument
efivar -l
, I started to display this variable, but the contents still, apparently, were not recorded:# efivar -p -n 926b68c6-77da-4cf6-ba58-2f27df0f705d-LoaderEntryOneShot
GUID: 926b68c6-77da-4cf6-ba58-2f27df0f705d
Name: "LoaderEntryOneShot"
Attributes:
Value:
man efivar
I looked, but this is one of the most pointless man pages I've ever seen.
Answer the question
In order to leave comments, you need to log in
What I learned from the documentation and links:
The name of the variable should be
LoaderEntryOneShot-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
- this is the GUID that the loader expects. mount -t efivarfs none /sys/firmware/efi/efivars
struct new_efi_variable {
u32 attributes;
u8 data[0];
};
#define EFI_VARIABLE_NON_VOLATILE 0x00000001
#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question