How to use qemu with UEFI on Ubuntu

In order to use QEMU with UEFI on Ubuntu first install OVMF:

sudo apt -y install ovmf

After that, use the -bios /usr/share/ovmf/OVMF.fd with QEMU, for example:

sudo qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -hda /dev/sdb -m 1024