This is a simple Python script to generate and dump OVMF_VARS.fd
files to and
from YAML. You can use this to generate OVMF_VARS.fd
files procedurally, as
well as examine their contents.
This is better than other solutions to modify OVMF_VARS.fd
because most other
solutions involve booting a UEFI shell inside a VM and using the UEFI APIs to
manipulate the variables. This script was written by reverse engineering the
format from the EDK2/OVMF source code. It's possible there are corner issues
with it, but it appears to work.
This tool probably won't work with OVMF_VARS.fd
which were not cleanly
written (e.g. the VM was terminated while variables were being modified) as it
doesn't implement the journaling functionality of the EDK2 variable store
format and assumes the store is clean.
- To get a human-readable dump of the variables in a file, run
ovmfvartool dump ./OVMF_VARS.fd
. - To get a YAML dump, run
ovmfvartool export ./OVMF_VARS.fd
. - To generate
OVMF_VARS.fd
from a YAML file, runovmfvartool compile vars.yaml OVMF_VARS.fd
. - To generate an empty
OVMF_VARS.fd
containing no variables (this is the same as the defaultOVMF_VARS.fd
distributed with OVMF builds), runovmfvartool generate-blank OVMF_VARS.fd
.
This tool might be useful in various circumstances, for example:
- To examine the contents of the UEFI variable store of a VM;
- To set UEFI parameters when launching a new VM from the outset.
An example of a YAML file generated by this tool can be found here. This particular example was generated after installing Windows into a VM.
© 2021 Hugo Landau. Licenced under the GPLv3 or later.