In my last post I've been testing the capability of qcow2 to shrink when data gets removed from the guest.
As discussed before, the guest need to have use 'SCSI' as Bus/Scsi (virtio-scsi) and the 'dicard' option checked.
Reading qm_virtual_machines_settings documentation page I see
So I tried to convert my qcow2 disk to raw format and play again the trick of adding and removing data from the guest.
I expected the raw file not to deallocate the space but it did!
Host
du -sh vm-107-disk-2.raw
1,1G vm-107-disk-2.raw
Guest
dd if=/dev/urandom of=c bs=1M count=1024
Host
du -sh vm-107-disk-2.raw
1,1G vm-107-disk-2.raw
Guest
rm c
sync
Host
du -sh vm-107-disk-2.raw
1,1G vm-107-disk-2.raw
The raw file is located in /var/lib/vz/images/107 (storage local).
Filesystem is ext4 and the local volume is THICK lvm.
So, or the documentation in wrong or I'm missing something.
As discussed before, the guest need to have use 'SCSI' as Bus/Scsi (virtio-scsi) and the 'dicard' option checked.
Reading qm_virtual_machines_settings documentation page I see
the raw disk image is a bit-to-bit image of a hard disk, similar to what you would get when executing the dd command on a block device in Linux. This format do not support thin provisioning or snapshotting by itself, requiring cooperation from the storage layer for these tasks
So I tried to convert my qcow2 disk to raw format and play again the trick of adding and removing data from the guest.
I expected the raw file not to deallocate the space but it did!
Host
du -sh vm-107-disk-2.raw
1,1G vm-107-disk-2.raw
Guest
dd if=/dev/urandom of=c bs=1M count=1024
Host
du -sh vm-107-disk-2.raw
1,1G vm-107-disk-2.raw
Guest
rm c
sync
Host
du -sh vm-107-disk-2.raw
1,1G vm-107-disk-2.raw
The raw file is located in /var/lib/vz/images/107 (storage local).
Filesystem is ext4 and the local volume is THICK lvm.
Code:
--- Logical volume ---
LV Path /dev/pve/root
LV Name root
VG Name pve
LV UUID JiqjHL-Sm4D-iA1k-5hqG-YzgX-3gpI-wSVkWS
LV Write Access read/write
LV Creation host, time vmserver, 2017-06-21 12:27:09 +0200
LV Status available
# open 1
LV Size 9,31 GiB
Current LE 2384
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
So, or the documentation in wrong or I'm missing something.