Converting between image formats using qemu-img

Converting images from one format to another is generally straightforward.

qemu-img is the tool which I use a lot. qemu-img can convert different fomat including raw, qcow2, qed, vdi, vmdk, vhd.

On Centos, qemu-img can only be installed on 64bit version.

As an example, I will show you how to convert Netscaler VPX raw image to qcow2 for my unetlab virtual appliance. If you want to know more about unetlab. Please go to http://www.unetlab.com

Step 1: Install qemu-img

yum install qemu-img

Step 2: Download the KVM version of Netscaler VPX and extract the raw image from the tgz file

tar -xzvf NSVPX-KVM-10.5-55.8_nc.tgz 

[root@localhost tmp]# ls -al NSVPX-KVM-10.5-55.8_nc.raw
-rw-r–r–. 1 root root 21474836480 Jan 25  2015 NSVPX-KVM-10.5-55.8_nc.raw

Step 3: convert the raw image to qcow2 format image

qemu-img convert -f raw -O qcow2 NSVPX-KVM-10.5-55.8_nc.raw virtioa.qcow2

Then you can see the qcow2 file

[root@localhost tmp]# ls -al

-rw-r–r–.  1 root   root     293076992 Aug  8 01:31 virtioa.qcow2

FYI:

VM format

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s