nbalonso.com

CentOS 7 UEFI Boot in KVM

| Comments

I rely heavily on virtualisation for testing things and making sure they work as they are supposed to.

Today I was trying to probe to a vendor that their Windows installer was failing in computers with big hard drives, so I went to my only box that has few TB of spare space and created a VM. The host computer is running CentOS 7 and I run KVM on it to virtualise things.

As I soon discovered KVM by default does not come with UEFI boot out of the box, so my Windows installation on a 3TB virtual drive was creating a 2TB partition and leaving the rest un-used. You probably knew that “legacy” boot mode only supports 2.2TB disks and that for bigger drives you must do a firmware boot (a.k.a. UEFI boot). If you didn’t know, now you do.

So this is how you install UEFI into KVM and configure your VM to use it.

Navigate to your repos folder and get the .repo file for kraxel

1
bash-3.2$ cd /etc/yum.repos.d/ && wget http://www.kraxel.org/repos/firmware.repo

Install the OVMF project for 64bit

1
bash-3.2$ su -c 'yum install edk2.git-ovmf-x64 -y'

You can check what files you just installed with

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
bash-3.2$ rpm -ql edk2.git-ovmf-x64
/usr/share/doc/edk2.git-ovmf-x64-0
/usr/share/doc/edk2.git-ovmf-x64-0/License.txt
/usr/share/doc/edk2.git-ovmf-x64-0/README
/usr/share/edk2.git
/usr/share/edk2.git/ovmf-x64
/usr/share/edk2.git/ovmf-x64/OVMF-pure-efi.fd
/usr/share/edk2.git/ovmf-x64/OVMF-with-csm.fd
/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd
/usr/share/edk2.git/ovmf-x64/OVMF_CODE-with-csm.fd
/usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd
/usr/share/edk2.git/ovmf-x64/OVMF_VARS-with-csm.fd
/usr/share/edk2.git/ovmf-x64/UefiShell.iso
/usr/share/edk2.git/ovmf-x64/bios.bin
/usr/share/edk2.git/ovmf-x64/efi-e1000.rom
/usr/share/edk2.git/ovmf-x64/efi-ne2k_pci.rom
/usr/share/edk2.git/ovmf-x64/efi-pcnet.rom
/usr/share/edk2.git/ovmf-x64/efi-rtl8139.rom
/usr/share/edk2.git/ovmf-x64/efi-virtio.rom
/usr/share/edk2.git/ovmf-x64/pxe-e1000.bin
/usr/share/edk2.git/ovmf-x64/pxe-e1000.rom
/usr/share/edk2.git/ovmf-x64/pxe-ne2k_pci.bin
/usr/share/edk2.git/ovmf-x64/pxe-ne2k_pci.rom
/usr/share/edk2.git/ovmf-x64/pxe-pcnet.bin
/usr/share/edk2.git/ovmf-x64/pxe-pcnet.rom
/usr/share/edk2.git/ovmf-x64/pxe-rtl8139.bin
/usr/share/edk2.git/ovmf-x64/pxe-rtl8139.rom
/usr/share/edk2.git/ovmf-x64/pxe-virtio.bin
/usr/share/edk2.git/ovmf-x64/pxe-virtio.rom
/usr/share/edk2.git/ovmf-x64/vgabios-cirrus.bin
/usr/share/edk2.git/ovmf-x64/vgabios-qxl.bin
/usr/share/edk2.git/ovmf-x64/vgabios-stdvga.bin
/usr/share/edk2.git/ovmf-x64/vgabios-virtio.bin
/usr/share/edk2.git/ovmf-x64/vgabios-vmware.bin

Create your VM as you normally would. You can use the gui tool virt-manager for example.

Once done and with you VM turned off, edit your VM’s xml with

1
bash-3.2$ su -c 'virsh edit <VMNAME>'

Search for the line that contains arch and paste the following line underneath

<loader>/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd</loader>

Write the changes and exit. Done! Now you can boot of the CD/DVD/PXE or any other method and it will be a UEFI boot.

You will know if you have done it properly because the VM will show the TianoCore  splash screen while booting.

Comments