In this example I'm working with a Red Hat 6.2 client (x86_64). As Hypervisor KVM is running. There are several VMware images available which I should running as a linux instance under KVM. So a conversation from vmdk to raw is necessary. After the conversion we'd join the new raw files into one img file. The following files are available:
3809775 0 -rw-rw-r--. 1 dswt dswt 0 Dec 31 2010 DA-HOST.vmsd
3809787 84K -rw-rw-r--. 1 dswt dswt 80K Dec 31 2010 vmware-1.log
3809786 124K -rw-rw-r--. 1 dswt dswt 120K Dec 31 2010 vmware-0.log
3809774 4.0K -rw-rw-r--. 1 dswt dswt 718 Jan 7 2011 DA-HOST.vmdk
3809788 4.0K -rw-rw-r--. 1 dswt dswt 3.2K Jan 7 2011 vprintproxy.log
3809785 176K -rw-rw-r--. 1 dswt dswt 171K Jan 7 2011 vmware.log
3809776 4.0K -rw-rw-r--. 1 dswt dswt 2.3K Jan 7 2011 DA-HOST.vmx
3809784 68K -rw-rw-r--. 1 dswt dswt 64K Jan 7 2011 DA-HOST-s007.vmdk
3809783 1.2G -rw-rw-r--. 1 dswt dswt 1.2G Jan 7 2011 DA-HOST-s006.vmdk
3809782 782M -rw-rw-r--. 1 dswt dswt 781M Jan 7 2011 DA-HOST-s005.vmdk
3809781 237M -rw-rw-r--. 1 dswt dswt 237M Jan 7 2011 DA-HOST-s004.vmdk
3809780 124M -rw-rw-r--. 1 dswt dswt 124M Jan 7 2011 DA-HOST-s003.vmdk
3809779 724M -rw-rw-r--. 1 dswt dswt 724M Jan 7 2011 DA-HOST-s002.vmdk
3809778 115M -rw-rw-r--. 1 dswt dswt 115M Jan 7 2011 DA-HOST-s001.vmdk
3809773 12K -rw-rw-r--. 1 dswt dswt 8.5K Jan 7 2011 DA-HOST.nvram
We use a small script named 'vmdk2raw' to realize that. Create it as root into the directory /usr/local/bin.
for i in `ls *[0-9].vmdk`; do
qemu-img convert -f vmdk $i -O raw ${i/vmdk/raw}
done
cat *.raw >> DA-HOST.img
Change into the directory where the vmdk files are located and start the script.
This might take a while. At the end there are the new raw and a new img files:
3809790 718M -rw-r--r--. 1 dswt dswt 2.0G Jan 14 08:51 DA-HOST-s002.raw
3809791 121M -rw-r--r--. 1 dswt dswt 2.0G Jan 14 08:51 DA-HOST-s003.raw
3809792 230M -rw-r--r--. 1 dswt dswt 2.0G Jan 14 08:51 DA-HOST-s004.raw
3809793 778M -rw-r--r--. 1 dswt dswt 2.0G Jan 14 08:52 DA-HOST-s005.raw
3809794 1.2G -rw-r--r--. 1 dswt dswt 2.0G Jan 14 08:52 DA-HOST-s006.raw
3809795 0 -rw-r--r--. 1 dswt dswt 6.0M Jan 14 08:52 DA-HOST-s007.raw
3809796 13G -rw-rw-r--. 1 root root 12G Jan 14 13:35 DA-HOST.img
Now you could define a new guest with KVM and use the new image.
Hint: It could be that the image couldn't start properly and message like the following appears:
waiting for device dev/sda1 to appear...
In that case shutdown the virtual linux instance (Force off). Open the linux instance using the Virtual Machine Manager of KVM.
Open the linux instance and click on 'Details'. On the right side under the title 'Virtual Disk' click on the 'Advanced options' and choose IDE instead of the default Virtio. Apply it and run a the machine again.
The post KVM: Convert vmdk to raw appeared first on Linux on the mainframe.