I successfully tested thin provisioning on lvm-thin.
I converted a lv into a qcow2 file.
The first thing I find strange is the file size that is equal to the virtual size (like a non allocated raw file).
Do you know why?
What I'm trying to achieve is to shrink the qcow2 file after data has been remove.
I expect that to work because qcow2 support discard.
Guest
dd if=/dev/urandom of=c bs=1M count=1024
Host
du -sh vm-107-disk-1.qcow2
2,1G vm-107-disk-1.qcow2
Guest
rm c
fstrim /
Host
du -sh vm-107-disk-1.qcow2
2,1G vm-107-disk-1.qcow2
As you can see, qcow2 doesn't shrink.
The storage is nfs.
I probably misunderstood something about thin-provisioning and qcow2.
What do you think about it?
I converted a lv into a qcow2 file.
Code:
create full clone of drive scsi0 (vm:vm-107-disk-1)
Formatting '/mnt/pve/nas-ufficio/images/107/vm-107-disk-1.qcow2', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536 preallocation=metadata lazy_refcounts=off refcount_bits=16
The first thing I find strange is the file size that is equal to the virtual size (like a non allocated raw file).
Do you know why?
Code:
ls -lh
-rw-r----- 1 root root 11G ott 21 18:15 vm-107-disk-1.qcow2
du -sh vm-107-disk-1.qcow2
1,1G vm-107-disk-1.qcow2
qemu-img info vm-107-disk-1.qcow2
image: vm-107-disk-1.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 1.1G
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
What I'm trying to achieve is to shrink the qcow2 file after data has been remove.
I expect that to work because qcow2 support discard.
Guest
dd if=/dev/urandom of=c bs=1M count=1024
Host
du -sh vm-107-disk-1.qcow2
2,1G vm-107-disk-1.qcow2
Guest
rm c
fstrim /
Host
du -sh vm-107-disk-1.qcow2
2,1G vm-107-disk-1.qcow2
As you can see, qcow2 doesn't shrink.
The storage is nfs.
I probably misunderstood something about thin-provisioning and qcow2.
What do you think about it?