29

I have a qcow2 image that I use to boot an installation of linux using QEMU; I would like to place the contents of that image directly onto a physical hard drive so that I can boot to that linux installation directly from my desktop. I would like to do something like dd if=my-qcow2.img of=/dev/sdb. However, this will clearly not work since qcow2 does not store the contents of the virtual disk in logical order within the qcow2 file. Any suggestions?

1 Answer 1

30

QEMU comes with the qemu-img program to convert between image formats.

qemu-img convert -f qcow2 -O raw my-qcow2.img /dev/sdb 
4
  • 3
    Pay attention that the QCOW2 format is Compressed! That means a 200GB QCOW2 image can convert into a 500GB hard drive... That may cause the "device is too small" error you are receiving imho Commented Jul 13, 2019 at 18:29
  • 12
    Old question, but: qemu-img nowadays features the dd subcommand, which I found slightly easier to understand. For example: qemu-img dd -f qcow2 -O raw bs=4M if=/vm-images/image.qcow2 of=/dev/sdd1. It works just like the usual standalone dd program. Commented May 14, 2020 at 14:42
  • It's failing with error while converting raw: Cannot grow device files error. Commented Apr 17, 2023 at 22:56
  • 3
    @recolic That means that the destination disk is smaller than the uncompressed image. Commented Jul 1, 2023 at 4:54

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.