TransWikia.com

How to boot a UEFI image from a KVM virtual machine without `virt-manager`? (e.g. Home Assistant on OpenMediaVault/Cockpit)

Super User Asked on January 1, 2022

Background

I would like to run Home Assistant (HASS) in a virtual machine on OpenMediaVault 5. Up until OMV 4, this was easy because OMV (and the underlying Debian) supported VirtualBox and VB apparently didn’t have any problems booting UEFI images. Because OMV 5 (and the underlying Debian 10) no longer support VirtualBox, OMV now uses KVM (libvirt) for virtual machines (and it supports Cockpit to manage them). Unfortunately, this entails that it is no longer trivial to boot UEFI images on OMV/Debian 10, and – you guessed it – the official Home Assistant image for KVM (QCOW2) needs UEFI and trying to import and boot it in Cockpit will fail. I was unable to find any button or command in Cockpit that allows me to set the boot mode to UEFI.

The challenge (in more generic terms)

So what I’m trying to achieve is to boot a QCOW2 image in UEFI mode on a headless system, i.e. without virt-manager. (If you are on a desktop machine, I believe you won’t have this problem but can just use virt-manager instead of Cockpit.)

So how do you do it?

One Answer

Disclaimer: I am not really familiar with UEFI, don't even know exactly what it does, so if this answer can be improved, please comment or edit accordingly.

This is what worked for me:

apt-get install ovmf
cd /usr/share/ovmf/

Check that the file OVMF.fd is there, because that is what libvirt needs to boot the image. (If yours is somewhere else for some reason, find it and change the path below accordingly.)

Assuming that you already have created a virtual machine called HASS (using the import image button in Cockpit and using the QCOW2 image provided on the home assistant installation page, you can now edit that VM on the command line (make sure the machine is turned off before proceeding):

virsh edit HASS

Locate the section, mine looked like this:

   <os>
     <type arch='x86_64' machine='pc-q35-3.1'>hvm</type>
     <boot dev='hd'/>
   </os>

And insert <loader readonly='yes' type='rom'>/usr/share/ovmf/OVMF.fd</loader> after the type tag:

   <os>
     <type arch='x86_64' machine='pc-q35-3.1'>hvm</type>
     <loader readonly='yes' type='rom'>/usr/share/ovmf/OVMF.fd</loader>
     <boot dev='hd'/>
   </os>

Save and exit and you're done. If you now start VM it should boot the HASS image.

Answered by Christoph on January 1, 2022

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP