Hi folks,
I have been studying QCOW2 file format for a couple of days, and I am
a little bit confused about whether QCOW2 supports UNMAP or not.
As I surf through internet, some mailing list discussion had mentioned
that qemu-nbd and nbd module both support UNMAP command.
So I follow the steps below on my machine (Ubuntu 13.10 with linux
kernel 3.12) to test if qemu-nbd and QCOW2 do support UNMAP.
1. Create a qcow2 file via qemu-img
> sudo qemu-img create -f qcow2 -o cluster_size=524288 base.qcow2 1G
2. Connect this qcow2 file with qemu-nbd
> sudo qemu-nbd -c /dev/nbd0 base.qcow2 --discard=unmap
3. Use sg_unmap command to issue UNMAP command to this NBD
> sudo sg_unmap --lba=0 --num=1 /dev/nbd0
Everytime I get the following error message:
unmap cdb: 42 00 00 00 00 00 00 00 18 00
unmap: pass through os error: Inappropriate ioctl for device
UNMAP failed (use '-v' to get more information)
I also try to format this nbd device with EXT4 and mount it, but still
cannot perform fstrim on the mount point.
Have I done anything wrong?
Any help would be grateful.
Thanks.
Best Regards,
Dennis