Search code examples
virtualboxqemuuefi

How to convert a qemu image (2 pflash + ide) to virtualbox vdi?


I am starting a VM with QEMU this way:

qemu-system-x86_64 \
    -m 512M \
    -drive file=ovmf.qcow2,if=pflash,format=qcow2,unit=0,readonly=on \
    -drive file=ovmf.vars.qcow2,if=pflash,format=qcow2,unit=1 \
    -nographic \
    -drive file=file.uefiimg,if=ide,format=raw

fdisk -l file.uefiimg output:

Disk file.uefiimg: 2 GiB, 2147483648 bytes, 4194304 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: DC9B048E-91D0-4DD0-BD7A-4D6130AA726F

Device          Start     End Sectors  Size Type
file.uefiimg1   16384   49151   32768   16M EFI System
file.uefiimg2   49152 1589247 1540096  752M Linux filesystem
file.uefiimg3 1589248 3129343 1540096  752M Linux filesystem
file.uefiimg4 3129344 4177919 1048576  512M Linux filesystem

Now the tricky part is that I would like to start this on Virtualbox. If not possible vmware is also an option. I tried converting the uefiimg to a raw image with VBoxManage then to vdi, without success. I think the main problem was that I need to include the qcow2 files. I read about those 2 files, inserted as pflash but I don't understand how to load them in VirtualBox (or if it's possible)


Solution

  • I converted the image to vdi with

    VBoxManage convertfromraw file.uefiimg --format vdi file.vdi

    Then, loaded this vdi and it works perfectly.