> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

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

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

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

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

```text theme={null}
efivar [-n name] [-f file] [-p] [-w]
```

命令选项：

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

## **更新** `OsIndications `**变量**

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

1. 创建一个包含特定字节序列 `04 00 00 00 00 00 00 00` 的 `data.hex` 文件。
   ```text theme={null}
   echo -e -n "\x4\x0\x0\x0\x0\x0\x0\x0" > data.hex
   ```
2. 将 `data.hex` 的内容写入 EFI 变量 `8be4df61-93ca-11d2-aa0d-00e098032b8c-OsIndications`。
   ```text theme={null}
   efivar -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-OsIndications -f data.hex -w
   ```
3. 要验证 EFI 变量 `8be4df61-93ca-11d2-aa0d-00e098032b8c-OsIndications` 的值，请运行以下命令：
   ```text theme={null}
   efivar -n 8be4df61-93ca-11d2-aa0d-00e098032b8c-OsIndications -p
   ```
   上一命令的输出：
   ```text theme={null}
   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
   ```

## **更新** `VendorDtbOverlays `**变量**

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

1. 创建一个包含数据 `camx` 的 `/var/data` 文件。
   ```text theme={null}
   echo -n "camx" > /var/data
   ```
2. 将 `/var/data` 的内容写入 EFI 变量 `882f8c2b-9646-435f-8de5-f208ff80c1bd-VendorDtbOverlays`。
   ```text theme={null}
   efivar -n 882f8c2b-9646-435f-8de5-f208ff80c1bd-VendorDtbOverlays -f /var/data -w
   ```
3. 要验证 EFI 变量 `882f8c2b-9646-435f-8de5-f208ff80c1bd-VendorDtbOverlays` 的值，请运行以下命令：
   ```text theme={null}
   efivar -n 882f8c2b-9646-435f-8de5-f208ff80c1bd-VendorDtbOverlays -p
   ```
   上一命令的输出：
   ```text theme={null}
   GUID: 882f8c2b-9646-435f-8de5-f208ff80c1bd
   Name: "VendorDtbOverlays"
   Attributes:
         Non-Volatile
         Boot Service Access
         Runtime Service Access
   Value:
   00000000  63 61 6d 78                                       |camx            |
   ```

## **后续步骤**

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