Émulateur Qemu - Kvm - Amorçage UEFI avec Secure Boot activé

Mise à jour : Debian 10.5 Buster

Ce document décrit comment lancer qemu avec l'amorçage UEFI lorsque Secure Boot est activé

Il fait suite aux documents

Référence

Sommaire

1 - Introduction

2 - Installation

$ aptitude versions ovmf
p 0~20181115.85588389-3+deb10u3 stable 500
i 2020.05-3~bpo+1 buster-backports 100
p 2020.11-2 testing 10 10
https://pkgs.org/search/?q=edk2-ovmf
$ mkdir ovmf_fedora31 && cd ovmf_fedora31

$ wget https://download-ib01.fedoraproject.org/pub/fedora/linux/releases/31/Everything/x86_64/os/Packages/e/edk2-ovmf-20190501stable-4.fc31.noarch.rpm
$ sudo aptitude install rpm2cpio

$ rpm2cpio edk2-ovmf-*.rpm | cpio -idmv
./usr/share/OVMF
./usr/share/OVMF/OVMF_CODE.fd
./usr/share/OVMF/OVMF_CODE.secboot.fd
./usr/share/OVMF/OVMF_VARS.fd
./usr/share/OVMF/OVMF_VARS.secboot.fd
./usr/share/OVMF/UefiShell.iso
./usr/share/doc/edk2-ovmf
./usr/share/doc/edk2-ovmf/README
./usr/share/doc/edk2-ovmf/ovmf-whitepaper-c770f8c.txt
./usr/share/edk2
./usr/share/edk2/ovmf
./usr/share/edk2/ovmf/EnrollDefaultKeys.efi
./usr/share/edk2/ovmf/OVMF_CODE.fd
./usr/share/edk2/ovmf/OVMF_CODE.secboot.fd
./usr/share/edk2/ovmf/OVMF_VARS.fd
./usr/share/edk2/ovmf/OVMF_VARS.secboot.fd
./usr/share/edk2/ovmf/Shell.efi
./usr/share/edk2/ovmf/UefiShell.iso
......
$ sudo mkdir -p /opt/suze/ovmf
$ sudo cp usr/share/edk2/ovmf/ /opt/suze/ovmf

3 - Utilisation

3.1 - Principe

$ mkdir debian-uefi_secure && cd debian-uefi_secure

$ cp /opt/suze/ovmf/OVMF_CODE.secboot.fd ./
$ cp /opt/suze/ovmf/OVMF_VARS.secboot.fd ./
-machine pc-q35-2.5 \
-drive if=pflash,format=raw,readonly,file=./OVMF_CODE.secboot.fd \
-drive if=pflash,format=raw,file=./OVMF_VARS.secboot.fd
-net none

3.2 - Test de l'amorçage UEFI en mode Secure Boot

$ cp /opt/suze/ovmf/OVMF_CODE.secboot.fd ./
$ cp /opt/suze/ovmf/OVMF_VARS.secboot.fd ./
$ qemu-system-x86_64 -machine pc-q35-2.5 \
-drive if=pflash,format=raw,readonly,file=./OVMF_CODE.secboot.fd \
-drive if=pflash,format=raw,file=./OVMF_VARS.secboot.fd \
-net none

3.3 - Amorçage de l'installateur Debian en mode secure boot

$ cp /opt/suze/ovmf/OVMF_CODE.secboot.fd ./
$ cp /opt/suze/ovmf/OVMF_VARS.secboot.fd ./
$ qemu-system-x86_64 -machine pc-q35-2.5 -m 2048 -enable-kvm -smp 4 -cpu host \
-drive if=pflash,format=raw,readonly,file=./OVMF_CODE.secboot.fd \
-drive if=pflash,format=raw,file=./OVMF_VARS.secboot.fd \
-drive format=raw,media=cdrom,file=debian10.iso \
-boot menu=on

3.4 - Installation d'un système Debian en mode secure boot

$ qemu-img create -f qcow2 debian.qcow2 20G
$ qemu-system-x86_64 -m 2048 -smp 4 -enable-kvm -cpu host \
-machine pc-q35-2.5 -boot order=c,once=d \
-drive if=pflash,format=raw,readonly,file=./OVMF_CODE.secboot.fd \
-drive if=pflash,format=raw,file=./OVMF_VARS.secboot.fd \
-drive format=raw,media=cdrom,file=debian10.iso \
-drive media=disk,format=qcow2,file=debian.qcow2
$ qemu-system-x86_64 -m 2048 -smp 4 -enable-kvm -cpu host \
-machine pc-q35-2.5 -boot order=c \
-drive if=pflash,format=raw,readonly,file=./OVMF_CODE.secboot.fd \
-drive if=pflash,format=raw,file=./OVMF_VARS.secboot.fd \
-drive format=raw,media=cdrom,file=debian10.iso

Annexe - ovmf debian

$ cp /usr/share/OVMF/OVMF_CODE.ms.fd ./
$ cp /usr/share/OVMF/OVMF_VARS.ms.fd ./
$ sudo qemu-system-x86_64 -enable-kvm -cpu host -machine pc-q35-2.5 -m 2048 -boot menu=on \
-drive if=pflash,format=raw,readonly,file=./OVMF_CODE.ms.fd \
-drive if=pflash,format=raw,file=./OVMF_VARS.ms.fd \
-drive format=raw,media=disk,file=vdisk.raw \
-global ICH9-LPC.disable_s3=1