How to boot a physical installation of windows 10 in a UEFI enabled QEMU environment with KVM?

Hello. I’m trying to boot a physical installation of windows 10 in a UEFI enabled QEMU environment with KVM. The windows 10 installation is on my disk /dev/sda. This is the partition table :

root@ziomario-Z390-AORUS-PRO:/var/log/libvirt/qemu# fdisk -l /dev/sda

Disk /dev/sda: 465,78 GiB, 500107862016 bytes, 976773168 sectors

Disk model: CT500MX500SSD4

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disklabel type: gpt

Disk identifier: A1F38312-1D0A-4947-A0C6-C7A7A4EB7266

Dispositivo Start Fine Settori Size Tipo

/dev/sda1 34 262177 262144 128M Microsoft reserved

/dev/sda2 264192 1286143 1021952 499M Windows recovery environment

/dev/sda3 1286144 1488895 202752 99M EFI System

/dev/sda4 1488896 975591423 974102528 464,5G Microsoft basic data

/dev/sda5 975591424 976773119 1181696 577M Windows recovery environment

So,I try to boot Windows 10 with this qemu command line :

qemu-system-x86_64 -bios /usr/share/OVMF/OVMF_CODE.fd -enable-kvm -cpu host -smp 4 -m 8192 -net nic,model=virtio -net user -drive file=/dev/sda,format=raw,if=virtio -vga qxl -usbdevice tablet -rtc base=utc

this is what happens:

it does not boot even /dev/sda1 or /dev/sda2 or /dev/sda3 or /dev/sda4. what’s the trick here ?

Firstly It’s good practice to use /dev/disk/by-id/<YOUR DRIVE NAME HERE>.

I suspect that your Windows drive does not have the necessary drivers installed to use if=virtio.

Try booting as an ide/sata drive. If that works, install the virtio drivers and go back to using virtio.