8

What are entries in /sys/firmware/efi/efivars/?

I see that they are small binary files. Are these addresses and the contents of the address? For example /sys/firmware/efi/efivars/BootFromUSB-ec87d643-eba4-4bb5-a1e5-3f3e36b20da9 in hexadecimal shows

000000000: 0700 0000 00                             ....

What does it mean?

2 Answers2

6

These are files in the efivars file system, which give you access to UEFI variables. For each UEFI variable there is one file in /sys/firmware/efi/efivars/.

Your example BootFromUSB-ec87d643-eba4-4bb5-a1e5-3f3e36b20da9 has the Name BootFromUSB and the VendorGuid ec87d643-eba4-4bb5-a1e5-3f3e36b20da9. The GUID makes sure that variables with the same name but from different vendors don't interfere. Some variables are defined in the UEFI specification, but not this one.

The first four bytes of the contents are attributes, which are also defined in the UEFI specification. The most important are

#define EFI_VARIABLE_NON_VOLATILE       0x00000001
#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
#define EFI_VARIABLE_RUNTIME_ACCESS     0x00000004

so your variable is non-volatile and can be accessed both at boot and at runtime.

Any remaining bytes are the value of the variable. In this case there is a single byte with the value 0.

You can use UEFI variables to influence the boot process. For example, we have used such a variable to switch the next boot to an alternative recovery firmware, when the standard firmware is not functioning.

Note that the efivars file system allows you to write to EFI variables by writing to the files. Be careful when you do this, as overwriting some variables may brick your system.

starblue
  • 626
1

EFIvars are part of the UEFI specification where some variable names have special meaning but most of them can be anything your UEFI firmware developer decided them to be.

jdwolf
  • 5,017