Skip to content

Instantly share code, notes, and snippets.

@djraw
Forked from denji/qcow2vdi.md
Created February 25, 2020 16:03
Show Gist options
  • Save djraw/18358272e0eba49c403e08993e8b8ca5 to your computer and use it in GitHub Desktop.
Save djraw/18358272e0eba49c403e08993e8b8ca5 to your computer and use it in GitHub Desktop.
convert a qcow2 vm to a VirtualBox vm format

VirtualBox command-line interface (VBoxManage) provides an easy way to convert raw disk image to the VDI/VMDK format and otherwise.

Let's assume that we have raw image of the sdb device:

$ sudo dd if=/dev/sdb of=./sdb.raw

To use it with VirtualBox we need to convert it to the VDI format:

$ VBoxManage convertdd sdb.raw sdb.vdi --format VDI

To use it with VMware we need to convert it to the VMDK format:

$ VBoxManage convertdd sdb.raw sdb.vmdk --format VMDK

Convert between VDI/VMDK formats:

$ VBoxManage clonehd sdb.vdi sdb.vmdk --format VMDK

$ VBoxManage clonehd sdb.vmdk sdb.vdi --format VDI

Convert to the RAW image:

$ VBoxManage clonehd sdb.vdi sdb.raw --format RAW

Alternative solution to get back raw image after applying modifications is to use qemu-img command from qemu package:

$ qemu-img convert -p -f vmdk sdb.vmdk -O raw sdb.raw

Now we can write image to the device:

$ sudo dd status=progress if=./sdb.raw of=/dev/sdb



# qemu-img convert -O vdi gnome.qcow2 gnome.vdi
# if its a raw image then: VBoxManage convertdd opnstk.raw VBox.vdi --format VDI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment