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?
Asked
Active
Viewed 3.0k times
22
Gilles 'SO- stop being evil'
- 807,993
- 194
- 1,674
- 2,175
Chris
- 813
- 2
- 7
- 11
1 Answers
23
QEMU comes with the qemu-img program to convert between image formats.
qemu-img convert -f qcow2 -O raw my-qcow2.img /dev/sdb
Gilles 'SO- stop being evil'
- 807,993
- 194
- 1,674
- 2,175
-
2Pay 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
-
8Old 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. – Binarus May 14 '20 at 14:42
-
It's failing with `error while converting raw: Cannot grow device files` error. – recolic Apr 17 '23 at 22:56
-
1@recolic That means that the destination disk is smaller than the uncompressed image. – Daniel Pereira Jul 01 '23 at 04:54