qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-discuss] qemu-img cannot format block device from qcow2 to raw


From: Max Reitz
Subject: Re: [Qemu-discuss] qemu-img cannot format block device from qcow2 to raw
Date: Mon, 8 May 2017 16:54:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1

On 08.05.2017 04:15, Han Han wrote:
> As subject, I tried to change block device from qcow2 to raw format,
> but it didn't make effect:
> # lsblk /dev/sdc
> NAME MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
> sdc    8:32   1 14.6G  0 disk
> 
> # qemu-img info /dev/sdc
> image: /dev/sdc
> file format: qcow2
> virtual size: 15G (15614803968 bytes)
> disk size: 0
> cluster_size: 65536
> Format specific information:
>     compat: 1.1
>     lazy refcounts: false
>     refcount bits: 16
>     corrupt: false
> 
> # qemu-img create /dev/sdc -f raw 15614803968
> Formatting '/dev/sdc', fmt=raw size=15614803968
> 
> # qemu-img info /dev/sdc
> image: /dev/sdc
> file format: qcow2
> virtual size: 15G (15614803968 bytes)
> disk size: 0
> cluster_size: 65536
> Format specific information:
>     compat: 1.1
>     lazy refcounts: false
>     refcount bits: 16
>     corrupt: false
> 
> As above, the format of block device was not changed.
> Is it a bug or designed as this?
> Thanks

Raw isn't really a format; any file is also a valid raw file. Therefore,
when "formatting" something as raw, normally nothing gets written to it.

qemu-img info just probes the image's format, and since it appears to be
a qcow2 file, it assumes it is. If no "real" format matches, it would
assume it's a raw image. You can circumvent this detection by specifying
a format manually with the -f parameter (qemu-img info -f raw /dev/sdc).

The same applies to qemu itself as well: You can pass a format using the
driver option for the respective -drive/-blockdev parameter, i.e. in
this case driver=raw. This should be done anyway because you should not
rely on qemu's probing effort to be correct, which you have seen
yourself: The image was detected to be a qcow2 image whereas it's
actually supposed to be a raw image.

Max

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]