Convert VDI (VirtualBox) to raw, qcow2, qed, vmdk, vhd in Windows
To convert a virtual machine in VDI format into row format we need VBoxManage.
Assuming you already have a virtual box, we go to the installation folder (typically C:\Program Files\Oracle\VirtualBox).
We must launch “cmd” or” powershell” from this folder. One solution is to click in the bar where there is the absolute path of the folder and write “cmd”. After this press Enter.
Now you should have this:
Now to convert the image you need to run the following command:
VBoxManage clonehd absolutepath/image.vdi image.img --format raw
Let’s see a practical example:
I have written the following command:
VBoxManage clonehd “C:\Users\Gio\VirtualBox VMs\Ubuntu64_OSSEC_Server\Ubuntu64_OSSEC_Server.vdi” “C:\Users\Gio\VirtualBox VMs\Ubuntu64_OSSEC_Server\OSSEC_Server.img” — format raw
The image also shows what happens after the command has been launched.
This is my result:
qemu-img
At the following link we can download the .exe for different VM conversions https://cloudbase.it/qemu-img-windows/ .
The procedure is the same as the previous one, just go to the folder you download and click in the bar where there is the absolute path of the folder and write “cmd”.
The command executed is
qemu-img convert -f raw -O qcow2 "C:\Users\Gio\VirtualBox VMs\Ubuntu64_OSSEC_Server\OSSEC_Server.img" "C:\Users\Gio\VirtualBox VMs\Ubuntu64_OSSEC_Server\OSSEC_Server.qcow2"
In summary, with the qemu-img convert command can do conversion between multiple formats, including qcow2, qed, raw, vdi, vhd and vmdk.
Reference
For QEMU https://www.qemu.org/
qemu-img for Windows https://cloudbase.it/qemu-img-windows/
For UUID in the shell https://it.wikipedia.org/wiki/Universally_unique_identifier