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

`efivar` 工具管理存储在非易失性固件存储中的统一可扩展固件接口 (UEFI) 环境变量。使用这些变量来配置 UEFI 固件及其环境。

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

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

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

命令选项：

- `-n name`：指定 UEFI 变量的名称。
- `-f file`：从文件加载或保存变量内容。
- `-p`：打印指定 UEFI 变量的值。
- `-w`：写入指定的 UEFI 变量。

## 更新 `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: Nov 04, 2025

[Previous Topic
从 SD 卡启动 Linux 操作系统](https://docs.qualcomm.com/bundle/publicresource/80-70022-27SC/topics/boot_linux_operating_system_from_sdcard.md) [Next Topic
自定义 Qualcomm Linux](https://docs.qualcomm.com/bundle/publicresource/80-70022-27SC/topics/customize_qualcomm_linux.md)