10

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

 2 years ago
source link: https://computingforgeeks.com/how-to-convert-virtualbox-disk-image-vdi-and-img-to-qcow2-format/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How To Convert VirtualBox Disk Image (VDI) and img to Qcow2 format

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:

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

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.

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.

More guides:

How to extend/increase KVM Virtual Machine (VM) disk size

How to Create CentOS / Fedora / RHEL VM Templates on KVM

How to Provision VMs on KVM with Terraform

How to run Minikube on KVM


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK