How to convert VirtualBox Disk Image (VDI) and img to Qcow2 format

This simple guide will show you the easiest way to convert a VDI disk image for use in the Openstack Cloud environment. It is easy to use and you only need to install a few packages.

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

Step-by-step guide on how to extend Vdi and VMDK hard drives on VirtualBox

Step-by-step guide on using existing virtual machines in Vagrant

The easiest way to create a Vagrant Box from an existing Virtualbox VM

What is Virtual Desktop Infrastructure (VDI)

Virtual Desktop Infrastructure (VDI) is defined as the process of hosting the desktop operating system in a virtual machine (VM) running on a centralized server. VDI is a variant of the client / server computing model and is 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 the QEMU processor emulator is Qcow / Qcow2. It represents a fixed-size block device in a file.

Qcow2 is an updated version of the qcow format, designed to replace it. The main difference from the original version is that qcow2 supports multiple virtual machine snapshots through a new flexible snapshot storage model. Users can easily convert qcow disk images to qcow2 format.

We will introduce the steps to convert VDI to Qcow on Fedora, CentOS and Ubuntu.

Fedora / CentOS 8:

Install qemu and kvm packages to use in the 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 the vdi image file

cd ~
cd VirtualBox VMs/ubuntu-server/

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

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

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

If the clone is successful, you should see a vdi disk image file.

Now, use Qemu to convert the created VDI to Qcow2 format. Basically, what we are doing is converting vdi to raw disk image.

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

Convert VDI to original img

If you want to create the original uncompressed image in .img format first, follow these steps.

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

Note: When you convert .vdi to .img, the .img format file is an uncompressed vdi, and it will be the maximum size that you set .vdi to, that is, the maximum size that can be increased to.

Convert .img to qcow2

You can also convert .img to qcow2

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

if you want .img Back to .vdiRun

VBoxManage convertdd ubuntu.img ubuntu.vdi 

That’s it. You have completed any of the above processes.

label:

  • How to convert .VMDK to .vdi format
  • How to convert .vdi to Qcow2 format
  • How to convert .img to .qcow2 format
  • How to convert .img to .vdi format
  • How to create .qcow2 and .img image formats from Virtualbox
  • Convert vmdk to vdi and img to qcow2 in Linux, Windows and VirtualBox.

How to expand / increase KVM virtual machine (VM) disk size

How to create a CentOS / Fedora / RHEL VM template on KVM

How to configure a VM on KVM using Terraform

How to run Minikube on KVM

Sidebar