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?
QEMU comes with the qemu-img
program to convert between image formats.
qemu-img convert -f qcow2 -O raw my-qcow2.img /dev/sdb
-
-
@Kais What's the problem? I haven't tested it recently, but it matches the documentation in Qemu 2.5. – Gilles 'SO- stop being evil' Jan 19 '18 at 7:58
-
When I enter the command I get "error while converting raw: Device is too small". But when I write the raw output using
dd
to the external drive, the error message doesn't appear. – user6039980 Jan 19 '18 at 14:37 -
1Pay 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 – Etamar Laron Jul 13 '19 at 18:29
-
1Old 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 standalonedd
program. – Binarus May 14 '20 at 14:42