Monday, February 8, 2016

how to convert a virtual box image to qcow2

I recently needed a KALI linux image in my openstack cluster. There was only a ova image provided by kali.org.

We need a Linux instance with around 4 CPU's and 4GB or RAM

Let's download the vbox image from https://www.offensive-security.com/kali-linux-vmware-virtualbox-
image-download/

Then extract:
(# apt-get install p7zip-full) <optional to install p7zip
# 7za e Kali-Linux-2.0.0-vbox-amd64.7z
Let's extract the ova file to review the VMDK files inside:

# file Kali-Linux-2.0.0-vbox-amd64.ova
Kali-Linux-2.0.0-vbox-amd64.ova: POSIX tar archive (GNU)

# tar -xvf Kali-Linux-2.0.0-vbox-amd64.ova
Kali-Linux-2.0.0-vbox-amd64.ovf
Kali-Linux-2.0.0-vbox-amd64-disk1.vmdk
Kali-Linux-2.0.0-vbox-amd64.mf
then convert the VMDK to a qcow2

# qemu-img convert -O qcow2 Kali-Linux-2.0.0-vbox-amd64-disk1.vmdk Kali-Linux-2.0.0-vbox-amd64-disk1.qcow2
Finally upload the converted image to glance using the glance client

# glance image-create --name "Kali2_64" --disk-format qcow2 --container-format bare --is-protected True < Kali-Linux-2.0.0-vbox-amd64-disk1.qcow2

The image is ready and we can boot an instance from it.

PS a side note for KALI linux: ssh server is not installed so you need to install it and start the service. To do that you better use the console login with root-toor credentials

This procedure should more or less be valid for almost any ova image. Please let me know if you make other conversions. 


No comments:

Post a Comment