Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

There is huge number of different formats for virtual storage files for desktop and server purposes (vmdk, qcow2, vdi, vdk, etc.). I'm writing a little script for manipulating them and would like the script to be able to distinguish between them.

Of course, it can be done via extension, but I want this to be more reliable. I tried commands file or qemu-img, but the results are not quite clear. Any idea improving my methods?

share|improve this question
    
Why are the results not clear - what are the results? Which file-version? –  Nils Dec 9 '12 at 22:16
    
Well.. I had strange results yesterday, because for .vmdk od .vdi qemu-img info gave me "raw". Since I created new different versions from original qcow2 and ran qemu-img info again, everthing looks just fine, even when I rewrite the extension of vmdk to vdi, it recognizes it. Thx for having me retry this.. –  Jakub Žitný Dec 11 '12 at 3:22
    
Perhaps file gave you "raw" while qemu-img info gave the right results? The file-command looks into the first few bytes and checks them against a regex in its "database". On Linux the file-extension does not matter much. –  Nils Dec 11 '12 at 22:10
add comment

1 Answer

up vote 1 down vote accepted

qemu-img info should be able to recognize all the formats QEMU understands. Unfortunately, even with the formats QEMU supports, the proprietary vendors change the format, so qemu-img can't always use them

share|improve this answer
    
Yes, qemu-img info is great way to do that.. Thanks.. –  Jakub Žitný Dec 11 '12 at 3:23
add comment

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.