Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect a QEMU image?

Tags:

qemu

I have a form where user can upload images (images of different OS).
How can I detect whether the image is QEMU image of type "qcow2" ?

like image 443
aka_007 Avatar asked Mar 23 '15 21:03

aka_007


People also ask

How do I run a qemu image?

To run it, download and unzip the image in a folder and run the QEMU command. Replace linux-0.2. img with the name of your guest OS image file. If it has a GUI and you want to use your mouse with it, double-click on the window and QEMU will grab your mouse.

How do I mount a qemu image?

You can mount a QEMU disk image using two basic methods: using an offset to mount the image directly, or using the libguestfs-tools package.

What is qemu image?

qemu-img command allows to inspect, check, create, convert, resize and take snapshot of qcow images. The e2fsprogs command e2image also has support for generating qcow2 files to avoid the use of sparse file support.


1 Answers

You can use qemu-img info to check the image format.

qemu-img info image-qcow.qcow2

the result will be something like this

image: image-qcow.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 136K
cluster_size: 65536

Source: http://lnx.cx/docs/vdg/html/ch02s03.html

After that, if you want to get the file format you can parse the output to get it.

Hope this helps

like image 151
CrApHeR Avatar answered Oct 16 '22 11:10

CrApHeR