Quantcast
Channel: Computing For Geeks
Viewing all articles
Browse latest Browse all 78

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

$
0
0

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 isntall few packages.We have covered many tutorials previously on VDI and VMDK including:

Step by step guide on how to extend Vdi and VMDK Hard disks on VirtualBox 

Step by step guide on using existing virtual machines with Vagrant

Easiest way to create Vagrant Box from existing Virtualbox VM

Let's first define VDI and Qcow2.
What is Virtual desktop infrastructure (VDI)
From Searchservervirtualization, 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.
Reference: Serchservervirtualization
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.
Reference: Wikipedia,
We'll cover steps of converting VDI to Qcow on the following host operating systems.
  1. Fedora
  2. CentOS
  3. RHEL
  4. Ubuntu/Debian
Fedora 23 Host
Install qemu and kvm packages to use in conversion

dnf -y install qemu-kvm libvirt virt-install bridge-utils 
Fedora 22 and below Host
yum -y install qemu-kvm libvirt virt-install bridge-utils
Ubunbtu/Debian Host
aptitude -y install qemu-kvm libvirt-bin virtinst bridge-utils
modprobe vhost_net
CentOS/RHEL Host
yum -y install qemu-kvm libvirt virt-install bridge-utils
Once qemu-kvm is installed, you can now convert vdi to qcow2. In my example, i will used vmdk image which i will first convert to vdi then do the conversion again to Qcow2.
Step 1: Navigate to the directory containing vdi image file
cd ~
cd VirtualBox\ VMs/ubuntu-server/
ls
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 

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.
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.
Tags:
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
Converting vmdk to vdi to img to qcow2 in Linux , Windows and VirtualBox.







Viewing all articles
Browse latest Browse all 78

Trending Articles