Ubuntu – How to convert qcow2 virtual disk to physical machine and reversely

kvm

I have a KVM Server and I am using qcow2 as vm image format

I need to convert virtual machines into physical machines

Any helpfull idea?

Best Answer

It's not even that hard, it just takes some time, a Ubuntu LiveCD, and an external USB disk (if you don't have more than one internal disks).

Preliminary step: Convert the disk to something useful

You can do this from your current system without having to boot to a LiveCD.

Load a terminal and fire in:

cd /media/wherever-the-image-is/

sudo apt-get install qemu-kvm

qemu-img convert test.qcow2 -O raw disk.img

Move /media/wherever-the-image-is/disk.img somewhere that you're not about to write to. If you're planning to write it to the disk that it's currently sitting on, you'll want to stick it on a separate internal disk, or, worst-comes-to-worst an external disk.

The following instructions assume you've moved it to /media/dave/disk.img (dave is an external USB disk)

Before you do any serious writing, make sure you have backups. CloneZilla can help you take whole disk backups if you have somewhere for that data to be stored.

Write the image to a disk of its very own

You'll want to do something like this. This assumes you're going to overwrite a whole disk.

Boot into an Ubuntu Live CD and click Try Ubuntu.

Mount your the place where your qcow2 image is being stored (eg the external USB disk as /media/dave). Do not mount the place where you want to write to.

Then we go to work:

sudo dd if=/media/dave/disk.img of=/dev/sdX

You want to replace sdX with the correct path to your destination disk. The sudo password is blank, just hit return.

You can then open gparted or something else and you should see your Ubuntu partition sitting on the disk. You should be able to expand it out.

Related Question