Home > Emulator > From Vmware to QEMU

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 Tags:
  1. January 3rd, 2007 at 20:06 | #1

    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).

  2. January 4th, 2007 at 19:10 | #2

    Poisoned your mind successfully. Welcome to QEMU. :P

  3. April 5th, 2007 at 12:02 | #3

    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

  4. Leonardo
    May 29th, 2007 at 02:54 | #4

    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

  5. Gustavo
    July 18th, 2007 at 07:37 | #5

    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.

  6. Lennox
    November 6th, 2007 at 09:30 | #6

    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!

  7. NonIdentity
    October 2nd, 2008 at 23:24 | #7

    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

  8. Billy
    October 13th, 2008 at 22:30 | #8

    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

  9. Vern
    April 9th, 2009 at 02:03 | #9

    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″.

  10. abhi
    October 28th, 2009 at 05:42 | #10

    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

  11. Anonymous
    June 1st, 2010 at 12:19 | #11

    @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

  1. February 26th, 2009 at 23:08 | #1