Virtual Guru's Blog – Home of Virtualization Workshops

July 24, 2008

Convert and Import VM Virtual Disk

Filed under: kvm, opensolaris, parallels, qemu, virtualbox, Virtualization, virtualpc, xen — natiku @ 6:57 am

This entry is part of Mastering Sun xVM VirtualBox


1. a) Use Virtual Disk in VMDK format directly in VirtualBox

Just point to VMDK file in VirtualBox Virtual Disk Manager and you are done

1. b) Convert VMware VMDK to VirtualBox native VDI format

1. Convert 2Gb sparse into monolithic sparse format using OVF tools

Convert it first to OVF and after back into vmdk, don’t select “flat or sparse”, OVF tool will by default create one sparse VMDK file.

head -n 20 "Solaris 10 u5 64-bit Console-1f-0.vmdk"
# Disk DescriptorFile
version=1
CID=04f9d350
parentCID=ffffffff
createType="monolithicSparse"
# Extent description
RW 31457280 SPARSE "Solaris 10 u5 64-bit Console-1f-0.vmdk"
# The Disk Data Base
#DDB
ddb.virtualHWVersion = "4"
ddb.uuid.modification = "5a62188a-8088-4ded-ba7a-2dda89bf8cfb"
ddb.toolsVersion = "0"
ddb.geometry.biosSectors = "63"
ddb.uuid.parent = "00000000-0000-0000-0000-000000000000"
ddb.adapterType = "ide"

2. Convert VMDK monolithic sparse format into VDI using qemu-img (with VDI support) on Linux

I try to use conversion procedure for which you don’t need to have twice disk space as is MAX disk size defined in VMDK file as it is used in procedures using RAW (unpacked) disk format.

In case of VMDK sized 1GB with MAX 15GB file RAW procedure will need minimum about 31GB:

1GB VMDK MF sparse , 15GB VMDK RAW, 15GB VDI VBox converdd, 1GB VDI VBOX compact

I will use on Linux HOST qemu-img tool with native VDI support and I will need only min 2x, max 4x size of actual virtual disk size:

1GB VMDK MF sparse, 1GB OVF , 1GB VMDK 1F sparse, 1GB VDI sparse

Compile qemu-imp tools with VDI support patch, there is an old patch from 2006, but recently pn 18 Jul 2008 Filip Navara post updated patch {Qemu-devel} Re: Updated VDI disk image support patch as qemu-vdi.zip

Download and unpack qemu 0.9.1 sources, patch it and compile qemu-img tool

 wget http://bellard.org/qemu/qemu-0.9.1.tar.gz
gtar xzvf qemu-0.9.1.tar.gz
patch -p0 <qemu-vdi.diff
./configure
make qemu-img
strip qemu-img
cp qemu-img /usr/local/bin/qemu-img-vdi

Check then VDI support is build in new qemu-img

qemu-img | grep "Supported format"
Supported format: parallels qcow2 vvfat vpc bochs dmg cloop vmdk qcow cow host_device raw
qemu-img-vdi | grep "Supported format"
Supported format: VDI parallels qcow2 vvfat vpc bochs dmg cloop vmdk qcow cow host_device raw

Now you can convert single file VMDK into VirtualBox native VDI format.

  /usr/local/bin/qemu-img-vdi convert "Solaris 10 u5 64-bit Console-1f-0.vmdk"  -O VDI "Solaris 10 u5 64-bit Console.vdi"
(VMDK) image open: flags=0x2 filename=Solaris 10 u5 64-bit Console-1f-0.vmdk
block-vdi.c:1362block-vdi.c:1377block-vdi.c:1401block-vdi.c:1432vdiCreateImage: done, filename="Solaris 10 u5 64-bit Console.vdi", rc=0

Now you can register in VirtualBox Virtual Disk Manager newly created .vdi file.

Advertisements

1 Comment »

  1. […] 1. Convert & Import VM Virtual Disk […]

    Pingback by Mastering Sun VirtualBox « Virtual Guru's Blog – Home of Virtualization Workshops — February 7, 2010 @ 5:56 pm


RSS feed for comments on this post. TrackBack URI

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

Blog at WordPress.com.

%d bloggers like this: