qcow2 shrinked file to raw file effective size problem

frhack

New Member
Dec 14, 2022
12
2
3
I followed the official guide in order to shrink a qcow2 file.

After the shrink if I move the file in the lvm-local-thin storage I get two different results:

if I move the disk when the VM is stopped then the data % is OK (the reduced one)
if I move the disk when the VM is running then the data % is 100 % (no shrink at all)

The Data% is the value obtained with the command:

Code:
lvs -a



Is there a way to shrink a VM file and move the file to the local-lvm-thin storage preserving the shrinkage and without shutdown the VM ?

thanks
Francesco
 
Last edited:
Hi,
what you can do is enable the discard option for the disk in the VM's Hardware tab, restart the VM from the UI to apply the change and run an fstrim -av inside the VM. You can also install the QEMU guest agent in the VM and enable it together with the fstrim_cloned_disks option in the Options tab, to have it happen automatically after disk move/clone: https://pve.proxmox.com/wiki/Qemu-guest-agent
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!