# QEMU and UEFI partition booting

## Bladesy

Hello all, I'm not sure if this is the right section for this, but I'm having trouble finding information about QEMU and UEFI.

I currently have a dual boot scenario with gentoo, windows and the efi partition on the same drive - both operating systems are booting UEFI.

The problem is, that I don't know how to boot windows from qemu when it boots as UEFI.

I believe that OVMF is needed to boot, and I'm able to use it for image files containing windows systems - but whenever I replace the image file with the location of my windows partition, it won't boot and returns to the yellow shell.

This is what I'm using at the minute to try and boot my windows partition:

```
#!/bin/bash

cp /usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd /tmp/my_vars.fd

qemu-system-x86_64 \

  -enable-kvm \

  -m 2048 \

  -cpu host,kvm=off \

  -vga none \

  -usb -usbdevice host:1017:0002 \

  -device vfio-pci,host=01:00.0,multifunction=on \

  -device vfio-pci,host=01:00.1 \

  -drive if=pflash,format=raw,readonly,file=/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd \

  -drive if=pflash,format=raw,file=/tmp/my_vars.fd \

  -device virtio-scsi-pci,id=scsi \

  -drive file=/mnt/virt.iso,id=virtiocd,if=none,format=raw -device ide-cd,bus=ide.1,drive=virtiocd \

  /dev/sda4

```

Note that /dev/sda4 is my windows partition, and /dev/sda1 is the efi parition, and /dev/sda5 is a 16M system reserved microsoft partition - but I'm not sure what it does.

What I'm thinking is that it isn't enough to just add the windows main partition, but I should add the efi and sys-reserved as well - but I'm not sure how to add them to QEMU.

----------

## szatox

I'm not quite sure whether qemu supports EFI mode mode by default or not. I know there is a patch for it, but it may not be included.

Also, since you seem to have windows installed in bare-metal fashion on that drive, you should provide the full drive to qemu. Let qemu look for a way to boot it, and then the OS installed on that drive to handle partitions. Being smart and providing only "necessary" partitions will strip some metadata (like partition table) making the whole thing unbootable - try this first, as it's much easier and faster to do than looking for patches  :Smile: 

----------

