From Vmware to QEMU
From QEMU home page,
QEMU is a generic and open source processor emulator which achieves a good emulation speed by using dynamic translation.
Why not qemu in the first place ? At first i was a big time qemu fan. But Windows XP and kqemu doesn’t work well most of the time. So, I need to move to VMware. Vmware workstation 5 seems to be much more faster compare to QEMU without kqemu. No doubt QEMU is much more light weight, but Vmware is still the way to go.
Now, I am back with QEMU. Also, I a some cool way to convert all my vmware files to qemu.
$ cd /path/to/vmware/guestos$ for i in `ls *[0-9].vmdk`; do qemu-img convert -f vmdk $i -O raw {i/vmdk/raw} ; done$ cat *.raw >> guestos.img
To run it,
$ qemu -m 256 -hda guestos.img
The downsite ? Most of us runs vmware with without preallocation space for virtual disk. So, when we make a conversion from vmware to qemu. The raw file will be the total space WITH preallocation.I am still testing with -f qcow format will it solve the problem or not.
Such as
$ for i in `ls *[0-9].vmdk`; do qemu-img convert -f vmdk $i -O qcow ${i/vmdk/qcow} ; done && cat *.qcow >> debian.img
Hopefully it works.
Categories: Emulator
Great tips! I didn’t know that we can combine numbers of vmdk to a single raw img using cat.By the way, there is a typo at command line in 2nd quote (second line).
Poisoned your mind successfully. Welcome to QEMU. :P
Hi, nice one-liner with the vmware to qemu conversion. I had to add a $ to the substitution part. Also you don’t need to use the backtick, and ls to get the list of files.
for i in *.vmdk; do qemu-img convert -f vmdk $i -O raw ${i/vmdk/raw} ; done
I surrounded $i with “” to convert images with spaces in between name like “Windows 2000.vmdk”.
for i in *.vmdk; do qemu-img convert -f vmdk “$i” -O raw ${i/vmdk/raw} ; done
I have a problem with the converted image. When I convert a vmdk image with a winXP guest, I can’t boot it in qemu.
This little tid bit you guys have provided here, has been tremendously helpfful in allowing me to back up my VM. The following is not the sweet little one-liners you all have above, but it solved my problem for a 32 GB VM, backing it up to an iMac.
vmdkFiles=$(find “/Volumes/Portable/Machines/Workhorse” -name “Windows*s0*.vmdk” -type f -print | perl -p -e s@’\n’@'%’@g);
IFS=”%”;
for vmdkFile in $vmdkFiles; do
newFile=$(echo “$vmdkFile” | perl -p -e s@’vmdk$’@'iso’@g | perl -p -e s@’/Volumes/Portable/Machines/Workhorse’@'/Users/asset/VMDKs’@g);
echo “Creating $newFile”;
/Users/asset/Q.app/contents/MacOS/qemu-img convert -f vmdk “$vmdkFile” “$newFile”;
echo “Appending $newFile to Workhorse.iso”;
cat $newFile >> ~/VMDKs/Workhorse.iso;
done;
echo “Operation Complete!”;
Left it to run overnight and presto!
The above works if you are root only. Also gaving the “$1″ dies not work i my case. Ubuntu 8.04.10 64Bit, I had to use just $1.
It is running now – will see how long it will take to run on Q6600 with 4GB
I was getting a message that said that it could not open “-O” on my FreeBSD box, so I make a slight adjustment to get it to run. Otherwise, thanks for the excellent trick.
for i in `ls *[0-9].vmdk`; do qemu-img convert -f vmdk -O raw $1 {i/vmdk/raw}; done
This posting is a bit old, but for future reference…
The command:
cat *.raw >> guestos.img
requires that the image files are:
1. All part of a single virtual hard drive (maybe even a single partition?)
2. All numbered with the same number of digits, since a “10″ appears before “9″.
hello,
my vmware image have 2 separate disks, [1 for os [osdisk-s001.vmkd ... osdisk-s011.vmdk] and the other for userdata/program [datadisk-s001.vmdk ... datadisk-s11.vmdk].
how would I convert so that when qemu boot the converted image file it can have data from both disks?
thanks
@abhi
To have two seperate disks:
qemu -hda osdisk-s001.vmkd -hdb datadisk-s001.vmdk -boot c
NOTE: These are not to be mistaken with seperate partitions