qemu-img: Could not open '/dev/stdin': Could not refresh total sector count: Operation not permitted

basin asked:

I want to transfer block device contents over the network directly into a qcow2 image. I started with a small simulation:

[root@okvmh1 default]# dd if=/dev/zero bs=1M count=100 | qemu-img convert -p -f raw -O qcow2 /dev/stdin aaa.qcow2
qemu-img: Could not open '/dev/stdin': Could not refresh total sector count: Operation not permitted
qemu-img: Could not open '/dev/stdin'

It seems that qemu-img does not know the desired image size. In VirtualBox I would do:

<net-command> | VBoxManage convertfromraw stdin aaa.vdi $size --format VDI

But qemu-img convert does not accept the size parameter.

My answer:


Standard input is not seekable, which is what qemu-img convert is trying to do here.

To work around the problem, use an input image which is a file on the filesystem or a block device, both of which are seekable.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.