How to shrink qcow2 disk when you can't copy it ?

aroger

Active Member
May 16, 2019
17
0
41
35
Hello

I have a qcow2 disk with a empty partition to remove (about 6.5Tb to remove) but I don't have enough place on my host to make a copy using qemu-img convert.

How could I achieve this ?

Thank you
 
hi,

you could attach it to a VM and use tools like fdisk or parted or any other partitioning tool.
 
Hey

I used gparted to reduce the partition size, there is now a new empty partition (who is not formated) but my proxmox host do not see any difference. The disk space is still full..
 
try
Code:
apt install libguestfs-tools
virt-sparsify --in-place disk.qcow2
 
  • Like
Reactions: aroger
try
Code:
apt install libguestfs-tools
virt-sparsify --in-place disk.qcow2

Well in fact it's worked but the size was growing back to the same as before.
When I try to run virt-sparsify again, it show finish with no error but space is not freed.

Code:
[   3.6] Trimming /dev/sda2
[   4.9] Clearing Linux swap on /dev/sda3
[   5.3] Trimming /dev/sda4
[  85.7] Sparsify in-place operation completed with no errors

Still looking for a solution.