Convert VirtualBox Disk Image (VDI) to Qcow2 format

Posted on 53 views

This simple guide will show you the easiest way to convert VDI disk image to use on your Openstack Cloud environment. It’s easy to use and you just have to install few packages.

We have covered many tutorials previously on VDI and VMDK including:

What is Virtual desktop infrastructure (VDI)

Virtual desktop infrastructure (VDI) is defined as the process of hosting a desktop operating system within a virtual machine (VM) running on a centralized server. VDI is a variation on the client/server computing model, sometimes referred to as server-based computing. The term was coined by VMware Inc.

What is QCOW2

One of the disk image formats supported by QEMU processor emulator is the Qcow/Qcow2. It is a representation of a fixed size block device in a file.

Qcow2 is an updated version of the qcow format, intended to supersede it. The main difference with the original is that qcow2 supports multiple virtual machine snapshots through a new, flexible model for storing snapshots. Users can easily convert qcow disk images to the qcow2 format.

We’ll cover steps of converting VDI to Qcow on the Fedora, CentOS and Ubuntu.

Fedora / CentOS 8:

Install qemu and kvm packages to use in conversion

sudo dnf -y install qemu-kvm libvirt virt-install bridge-utils 

CentOS 7

sudo yum -y install qemu-kvm libvirt virt-install bridge-utils

Ubuntu / Debian:

sudo apt-get -y install qemu-kvm libvirt-bin virtinst bridge-utils

Convert vdi to qcow2.

Navigate to the directory containing vdi image file

cd ~
cd VirtualBox VMs/ubuntu-server/

As you can see, i have VMDK file called box-disk1.vmdk, i will first clone it to VDI format then make qcow2 image.

The following command is used to clone vmdk to vdi. The virtual appliance should be off.

VBoxManage clonehd box-disk1.vmdk ubuntu.vdi --format vdi

If it’s successful on cloning, you should see a vdi disk image file.

Now lets convert VDI created to Qcow2 format using qemu. Basically what we are doing is converting vdi to a raw disk images.

qemu-img convert -f vdi -O qcow2 ubuntu.vdi ubuntu.qcow2 


Convert vdi to raw img

In case you would like to first create raw uncompressed image of format .img, here is how to do it.

VBoxManage clonehd --format RAW ubuntu.vdi ubuntu.img

NOTE: When you do convert a .vdi to a .img, The format .img file is uncompressed vdi and it will be the maximum size that you set your .vdi to grow up to, maximum size it can grow up to.

Convert .img to qcow2

You can as well convert .img to qcow2

qemu-img convert -f raw ubuntu.img -O qcow2 ubuntu.qcow2 

If you would like to .img back to .vdi, run

VBoxManage convertdd ubuntu.img ubuntu.vdi 

That’s all.You are done doing any of above processes.


Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.