# Enable secure boot for QEMU

**URL:** https://discourse.nixos.org/t/enable-secure-boot-for-qemu/15718
**Category:** Uncategorized
**Created:** [October 28, 2021, 2:28am UTC](https://discourse.nixos.org/t/enable-secure-boot-for-qemu/15718 "2021-10-28T02:28:59Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![vccs](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/v/cab0a1/32.png) [@vccs](https://discourse.nixos.org/u/vccs)
#### Post date: [October 28, 2021, 2:28am UTC](https://discourse.nixos.org/t/enable-secure-boot-for-qemu/15718/1 "2021-10-28T02:28:59Z")

</div>

I use libvirtd modules OVMFFull from unstable.

```nix
  virtualisation.libvirtd = {
    enable = true;
    qemu.ovmf.package = pkgs.unstable.OVMFFull;
  };

```

In documents from other distributions there is a `OVMF_CODE.secboot.fd` but I can only find a `OVMF_CODE.fd`. Finally I just use `OVMF_CODE.secboot.fd` and `OVMF_VARS.ms.fd` from debian and everything just works. What’s the recommanded method to do this? Something like the debian packages which works out of the box is helpful.

---

<div class="post-metadata">

### Author: ![ius](https://discourse.nixos.org/user_avatar/discourse.nixos.org/ius/32/4508_2.png) [@ius](https://discourse.nixos.org/u/ius)
#### Post date: [October 28, 2021, 12:13pm UTC](https://discourse.nixos.org/t/enable-secure-boot-for-qemu/15718/2 "2021-10-28T12:13:07Z")

</div>

Qemu includes `edk2-x86_64-secure-code.fd` and `edk2-i386-vars.fd`

`/nix/store/d2v4yzk2n9hl8nakbsb1sd4wvmk5k8bp-qemu-6.0.0/share/qemu/edk2-x86_64-secure-code.fd`

---

<div class="post-metadata">

### Author: ![vccs](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/v/cab0a1/32.png) [@vccs](https://discourse.nixos.org/u/vccs)
#### Post date: [October 28, 2021, 2:21pm UTC](https://discourse.nixos.org/t/enable-secure-boot-for-qemu/15718/3 "2021-10-28T14:21:06Z")

</div>

Oh, yes! Not sure how I should use it. It’s not shown in virt-manager.

---

<div class="post-metadata">

### Author: ![ius](https://discourse.nixos.org/user_avatar/discourse.nixos.org/ius/32/4508_2.png) [@ius](https://discourse.nixos.org/u/ius)
#### Post date: [October 28, 2021, 8:49pm UTC](https://discourse.nixos.org/t/enable-secure-boot-for-qemu/15718/4 "2021-10-28T20:49:35Z")

</div>

I don’t know how they’re registered in `virt-manager`, but in any case you should be able to edit the libvirt xml directly. Use your OVMF workaround to see what the xml should look like if necessary.

---

<div class="post-metadata">

### Author: ![vccs](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/v/cab0a1/32.png) [@vccs](https://discourse.nixos.org/u/vccs)
#### Post date: [October 29, 2021, 1:28am UTC](https://discourse.nixos.org/t/enable-secure-boot-for-qemu/15718/5 "2021-10-29T01:28:13Z")

</div>

Yes, editing the xml works. It would be great to have it out of the box if possible.

---

<div class="post-metadata">

### Author: ![noblman](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/n/b487fb/32.png) [@noblman](https://discourse.nixos.org/u/noblman)
#### Post date: [March 29, 2022, 9:04pm UTC](https://discourse.nixos.org/t/enable-secure-boot-for-qemu/15718/6 "2022-03-29T21:04:31Z")

</div>

Is there a solution to this that doesn’t involve manually editing an xml file?

If not, could someone post the instructions for manually editing the xml file.

Is it necessary to use the unstable OVMFFull package?

---

<div class="post-metadata">

### Author: ![vccs](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/v/cab0a1/32.png) [@vccs](https://discourse.nixos.org/u/vccs)
#### Post date: [March 30, 2022, 10:23am UTC](https://discourse.nixos.org/t/enable-secure-boot-for-qemu/15718/7 "2022-03-30T10:23:29Z")

</div>

There are many posts on the Internet about the xml file. Basically this is needed.

```auto
<os>
  <loader readonly="yes" secure="yes" type="pflash">/path/to/OVMF_CODE.secboot.fd</loader>
  <nvram>/path/to/OVMF_VARS.secboot.fd</nvram>
</os>

```

```auto
<features>
  <smm state="on"/>
</features>

```

You can edit the xml file in virt-manager or gnome boxes.

I didn’t use the OVMF from NixOS. It doesn’t work for me. I guess it’s not signed by Microsoft. The files from CentOS works for me. You can get them from [CentOS Mirror](http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/), search the edk2-ovmf.

---

<div class="post-metadata">

### Author: ![ChocolateLoverRaj](https://discourse.nixos.org/user_avatar/discourse.nixos.org/chocolateloverraj/32/16594_2.png) [@ChocolateLoverRaj](https://discourse.nixos.org/u/ChocolateLoverRaj)
#### Post date: [April 27, 2024, 7:13pm UTC](https://discourse.nixos.org/t/enable-secure-boot-for-qemu/15718/8 "2024-04-27T19:13:05Z")

</div>

How do you get the `OVMF_CODE.secboot.fd` file in NixOS? And if it’s already in `/nix`, how do I find where it is?

---

<div class="post-metadata">

### Author: ![vccs](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/v/cab0a1/32.png) [@vccs](https://discourse.nixos.org/u/vccs)
#### Post date: [April 28, 2024, 5:05am UTC](https://discourse.nixos.org/t/enable-secure-boot-for-qemu/15718/9 "2024-04-28T05:05:14Z")

</div>

I don’t get it from NixOS. I put it in my home.

---

<div class="post-metadata">

### Author: ![ChocolateLoverRaj](https://discourse.nixos.org/user_avatar/discourse.nixos.org/chocolateloverraj/32/16594_2.png) [@ChocolateLoverRaj](https://discourse.nixos.org/u/ChocolateLoverRaj)
#### Post date: [April 28, 2024, 5:41am UTC](https://discourse.nixos.org/t/enable-secure-boot-for-qemu/15718/10 "2024-04-28T05:41:56Z")

</div>

> [@vccs](#):
>
> `<smm state="on"/>`

Thanks. After downloading `edk2-ovmf` RPM from the CentOS Mirror and extracting it to my home directory, and following your instructions, I have the option to enable SecureBooot.
