Home KVM Enable UEFI Support For KVM Virtual Machines In Linux

Enable UEFI Support For KVM Virtual Machines In Linux

By sk
Published: Updated: 109.5K views

The BIOS initializes the hardware and loads the OS into memory. BIOS is replaced with UEFI in the modern hardware. This guide explains what is UEFI and how to enable UEFI support for KVM virtual machines in Linux.

What is UEFI?

UEFI, short for Unified Extensible Firmware Interface, is the new replacement for traditional BIOS.

Unlike BIOS, UEFI is a tiny operating system that sits on the top of the computer's hardware and firmware. Remember BIOS is stored in firmware.

UEFI can do a lot more than a BIOS. We can store it in a flash memory on the motherboard, or it can be stored on a hard drive, or even on a network share.

The original motivation to replace legacy BIOS with UEFI was born during early development of the first Intel-HP Itanium systems in the mid-1990s.

Due to the BIOS limitations for larger server platforms, Intel started to work on the "Intel Boot Initiative" in 1998. It is later known as Extensible Firmware Interface (EFI).

Apple has adopted EFI for its Intel-based Mac systems and HP adopted EFI for its Itanium 2 servers. However, the other Chip vendors were not much interested to adopt Intel's EFI.

In 2005, a non-profit organization named Unified EFI Forum was formed by a group of leading technology companies including AMD, American Megatrends, ARM, Apple, Dell, Hewlett Packard Enterprise, HP Inc., IBM, Insyde Software, Intel, Lenovo, Microsoft, and Phoenix Technologies.

The board of directors of UEFI Forum includes representatives from all of these thirteen companies.

Using the EFI 1.10 Specification as the starting point, the UEFI Forum took over the development and renamed it as Unified EFI starting with version 2.0.

They agreed UEFI as the universal replacement for BIOS and took the responsibility for the management and promotion of UEFI specification.

UEFI Advantages

The UEFI specification provides many significant advantages over the legacy BIOS. Here are a few notable features:

  • Support for hard drive partitions larger than 2.2 TB or more in size.
  • UEFI replaces MBR with GPT partitioning, so you can now have for more than four primary  partitions on a drive.
  • UEFI Secure Boot feature helps defend against malware attacks before the operating system loads,
  • Faster boot time.
  • Stylish user interface, including graphics and mouse cursor support.
  • Efficient power and system management.
  • Robust reliability and fault management.
  • Backward and forward compatibility.

Please note that you can't replace BIOS with UEFI in the existing hardware. You need to buy a hardware that supports and includes UEFI.

UEFI specifications are platform-independent, supporting multiple platforms and architectures. Hope you got the basic understanding of UEFI. Let us now see how to enable UEFI support for KVM guests.

Enable UEFI Support for KVM Virtual Machines in Linux

I assume you already installed KVM on your system. If you haven't installed yet, check the following guides:

Before creating virtual machines, we need to install OVMF package on the KVM host system.

OVMF is a port of Intel's tianocore firmware to the KVM/QEMU virtual machines. It contains sample UEFI firmware for both KVM and QEMU.

It allows easy debugging and experimentation with UEFI firmware either for testing virtual machines or using the (included) EFI shell.

The UEFI might be already installed as a dependency when installing KVM. Just in case if it is not installed, you can install it as shown below.

If your KVM host is running with CentOS/RHEL, run to install UEFI Firmware for Virtual Machines:

$ sudo dnf install edk2-ovmf

If you host system is Ubuntu, run:

$ sudo apt install ovmf

Done! We have just enabled UEFI support. Let us create a virtual machine with UEFI support.

Boot Virtual Machines with UEFI

If you prefer command line mode, add --boot uefi option when creating a new virtual machine:

$ virt-install --name centos8 --ram=2048 --vcpus=1 --cpu host --hvm --disk path=/var/lib/libvirt/images/centos8-vm1,size=10 --location /home/ostechnix/centos8.iso --network bridge=br0 --graphics vnc --boot uefi

Alternatively, you can use Virt-manager GUI application to create a new guest. It is very easier for newbies.

Open Virt-manager application and create a new virtual machine:

Create a new KVM virtual machine from Virt-manager
Create a new KVM virtual machine from Virt-manager

Choose the installation medium or ISO file location for your KVM guest:

Choose install medium or iso for kvm virtual machine
Choose install medium or iso for kvm virtual machine

Choose the memory and cpu core for the KVM guest:

Choose memory and cpu core for KVM virtual machine
Choose memory and cpu core for KVM virtual machine

Create a disk image for the KVM guest:

Create a disk image for the KVM virtual machine
Create a disk image for the KVM virtual machine

Check "Customize configuration before install" box and click Finish button:

Customize KVM virtual machine configuration before install
Customize KVM virtual machine configuration before install

You should now see the Virtual machine's hardware details. From the Overview section, choose "UEFI X86_64..." option from the Firmware drop-down box.

Choose UEFI from Firmware drop-down box in Virt-manager
Choose UEFI from Firmware drop-down box in Virt-manager

Click Apply button and  then click "Begin Installation" button on the top to continue installing the KVM guest machine.

Now your should see the TianoCore splash screen when initial boot:

Enable UEFI support for KVM virtual machines
Enable UEFI support for KVM virtual machines

Continue and finish the installation as usual.

UEFI settings interface

With traditional BIOS, you have to hit the appropriate Function key before boot menu appears to enter into BIOS and modify any BIOS settings. In UEFI, it is not necessary. You can access the UEFI settings screen right from the Grub boot menu.

If UEFI support is enabled on KVM, you should see the "System setup" menu entry in the Grub boot menu:

System setup in Grub boot menu
System setup in Grub boot menu

Enter into System setup to see how UEFI settings interface looks like.

UEFI interface
UEFI interface

You might see different UEFI interface with different features on your physical system. Many PCs still ship with text-mode UEFI settings interfaces that look and work like the old BIOS setup screen as shown here.

Text-mode UEFI settings interface

After making any changes in your PC's firmware, choose "Continue" and hit ENTER to go back to the boot menu.


You May Also Like


Kathrin December 13, 2021 - 7:56 am

This is all bullshit. GPT partitioning support depends on the operating system. I have been running Linux on 6 TiB GPT partioned drives on a BIOS system for years now. Also UEFI does in no way speed up system bootup. Graphical Bios Setup utilities have existed before UEFI, and most UEFI system do NOT have them. It is true that UEFI obsoletes the need for some workarounds, but none of its features are in any way advantageous for virtual machines.

kinghat December 15, 2021 - 11:40 pm

says here that you can change the firmware in cockpit to uefi but i dont see how you can do that: https://cockpit-project.org/blog/cockpit-213.html

sk December 16, 2021 - 3:39 pm

Update Cockpit and try. It might be there.

Ashish Gupta January 21, 2022 - 4:28 pm

when i am giving this command getting list any idea
$ virsh net-dhcp-leases default

sk January 21, 2022 - 9:04 pm

Can you please elaborate your question? I can’t understand what you’re trying to say.

Todd January 21, 2022 - 9:39 pm

Hi thank you for the article! Do you know if Windows 7 UEFi partitions will boot in KVM/QEMU? Virtualbox specifically called out it was not supported 5 years ago, and its still failing me using disk2vhd snapshots from a physical server…

sk January 21, 2022 - 10:00 pm

Never Tried Windows 7 UEFI in KVM/QEMU. So I can’t comment about it. Please check it yourself.

M. November 8, 2022 - 1:54 am

Thank you!


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More