# 使用 efivar 工具管理 UEFI 环境变量

efivar 工具管理存储在非易失性固件存储中的 UEFI 环境变量。使用这些变量来配置 UEFI 固件及其环境。

efivars 是存储在 UEFI 固件中的键值对。它们保存启动配置、系统状态和其他必要参数的设置。efivars 管理启动项和固件设置，确保系统正确启动并维护其配置。

要与 UEFI 环境变量交互，请使用以下命令：

efivar [-n name] [-f file] [-p] [-w]
    Copy to clipboard

命令选项：

-n name: Specify the name of the UEFI variable.
    -f file: Load or save variable contents from a file.
    -p: Print the value of the specified UEFI variable.
    -w: Write to the specified UEFI variable.
    Copy to clipboard

## 更新 OsIndications 变量

要更新 OsIndications 变量并验证 EFI 变量的值，请执行以下操作：

1. 创建一个包含特定字节序列 `04 00 00 00 00 00 00 00` 的 `data.hex` 文件。

echo -e -n "\x4\x0\x0\x0\x0\x0\x0\x0" > data.hex
        Copy to clipboard
2. 将 `data.hex` 内容写入到 EFI 变量 `8be4df61-93ca-11d2-aa0d-00e098032b8c-OsIndications`。

efivar -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-OsIndications -f data.hex -w
        Copy to clipboard
3. 要验证 EFI 变量 `8be4df61-93ca-11d2-aa0d-00e098032b8c-OsIndications` 的值，请运行以下命令：

efivar -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-OsIndications -p
        Copy to clipboard

    上一个命令的输出：

GUID: 8be4df61-93ca-11d2-aa0d-00e098032b8c
        Name: "OsIndications"
        Attributes:
              Non-Volatile
              Boot Service Access
              Runtime Service Access
        Value:
        00000000  04 00 00 00 00 00 00 00
        Copy to clipboard

有关详细信息，请参阅 [efivars 手册](https://man.freebsd.org/cgi/man.cgi?query=efivar&amp;sektion=8)。

Last Published: Jul 24, 2025

[Previous Topic
从 SD 卡启动 Linux 操作系统](https://docs.qualcomm.com/bundle/publicresource/80-70020-27SC/topics/boot_linux_operating_system_from_sdcard.md) [Next Topic
用户定制](https://docs.qualcomm.com/bundle/publicresource/80-70020-27SC/topics/user_customizations.md)