Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a VMDK disk image that exists as multiple files:

2.0G guest-s001.vmdk  1.8G guest-s003.vmdk  128K guest-s005.vmdk
2.0G guest-s002.vmdk  1.7G guest-s004.vmdk  4.0K guest.vmdk

When running qemu-img to convert it to the qcow2 format, which input filename(s) should I specify? Just guest.vmdk, all of them, or something like guest-*.vmdk?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

In the past, I've had to convert them first to raw images, concatenate them together, and then convert the resulting raw image to qcow2:

qemu-img convert guest-s001.vmdk guest-s0001.raw
qemu-img convert guest-s002.vmdk guest-s0002.raw
qemu-img convert guest-s003.vmdk guest-s0003.raw
qemu-img convert guest-s004.vmdk guest-s0004.raw
qemu-img convert guest-s005.vmdk guest-s0005.raw
cat guest-s0001.raw guest-s0002.raw guest-s0003.raw guest-s0004.raw guest-s0005.raw > guest.raw
qemu-img convert guest.raw guest.qcow2

Don't panic if more than just the last file is smaller than 2146762752 bytes. Some VMware products create vmdk spans with different sizes. The size should match 512 times the number of sectors listed in the extent description in the main vmdk file (readable with any text editor or "cat").

It may be possible to do this all at once too, but I haven't tried this:

qemu-img convert guest-s001.vmdk guest-s002.vmdk guest-s003.vmdk guest-s004.vmdk guest-s005.vmdk guest.qcow2

Or, if they're not actually contiguous disk images, then I'm not sure what to suggest. :)

Good luck!

share|improve this answer
    
qemu-img convert guest-s001.vmdk guest-s002.vmdk guest-s003.vmdk guest-s004.vmdk guest-s005.vmdk guest.qcow2 this method is possible, quick, comfortable !!!! Thank you :) –  Ubuntu Master Jan 16 '11 at 13:17

I'm trying this to convert to raw:

find . -type f -iname <guest-name>\*-f0\*vmdk -exec qemu-img convert {} {}.raw \;

Then to catenate:

cat <guest-name>*-f0[0-1][1-9]*raw >> <guest-name>.raw

Then to convert:

qemu-img convert <guest-name>.raw -O qcow2 <guest-name>.qcow2
share|improve this answer
    
Wow that screwed up anything inside greater than or less than signs. :( Don't bother using it. –  user9684 Jan 27 '11 at 0:48
    
I've edited your post so it shows up correctly. Here's the explanation. –  ændrük Jan 27 '11 at 16:41

I could have used parallel to do this but here is one that will do the directory:

ls *s0??.vdmk | xargs -n 2 -I % qemu-img convert % %.img

And then:

cat *.img >> imagename.raw

The ls part before the pipe will print all vdmk that have at the end an s0 and two wildcards the xargs command allows it to substitute % twice as a variable to the end of the qemu-img command.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.