# 使用 efivar 工具管理 UEFI 環境變數

efivar 工具管理儲存在非揮發性韌體儲存裝置中的 UEFI 環境變數。使用這些變數配置 UEFI 韌體及其環境。

efivar 是儲存在 UEFI 韌體中的鍵值對。它們保存啟動組態、系統狀態及其他基本參數的設定。efivar 管理啟動項目和韌體設定，確保系統正確啟動並維持其組態。

若要與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: Dec 23, 2025

[Previous Topic
從 SD 卡啟動 Linux 作業系統](https://docs.qualcomm.com/bundle/publicresource/80-70020-27TC/topics/boot_linux_operating_system_from_sdcard.md) [Next Topic
使用者自訂](https://docs.qualcomm.com/bundle/publicresource/80-70020-27TC/topics/user_customizations.md)