[SOLVED] shrink qcow2 vm

bumann

Renowned Member
May 1, 2016
30
1
73
40
Hi,

i want to shrink a vm. it is a linux vm. In the vm the system tells me a used space of 2.3gb data. The disk in Proxmox is 8tb.
The file system shows me a size of 12tb. I use fstrim -av inside the vm. it shows me it shrinked 5.5gb. But the file on filesystem is still 12TB.
After a reboot of the vm, the fstrim shows me 5.5gb shrinked again.

I think there are some broken snapshots in the image, i cant delete. if i want to delete the snapshots via qemu-img "file did not exist".
I think a few month ago i delete the snapshots from the .conf.

The problem is i want to transfer the image to another storage, but 12tb takes to long downtime .... :-(

Here is the output after the fstrim -av in the vm

qemu-img info vm-104-disk-0.qcow2
image: vm-104-disk-0.qcow2
file format: qcow2
virtual size: 7.81 TiB (8589934592000 bytes)
disk size: 5.72 TiB
cluster_size: 65536
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 symlink 0 B 2019-11-24 11:12:33 4054:20:18.965
2 xxx_symlink 0 B 2019-11-25 10:16:09 4077:23:45.073
3 funzt_xxx 0 B 2019-11-25 21:20:23 4088:27:55.691
4 vor_update_01122019 0 B 2019-12-01 14:06:24 4225:13:52.373
11 yyy_xxxx_update 0 B 2021-04-13 10:55:33 2177:05:24.086
Format specific information:
compat: 1.1
compression type: zlib
lazy refcounts: false
refcount bits: 16
corrupt: false
 
hi,

The file system shows me a size of 12tb. I use fstrim -av inside the vm. it shows me it shrinked 5.5gb. But the file on filesystem is still 12TB.
After a reboot of the vm, the fstrim shows me 5.5gb shrinked again

please take a look at [0]

you should fill your disk with zeroes (dd if=/dev/null of=tempfile and then delete this file with rm -f tempfile, afterwards run fstrim and the disk size should shrink

[0]: https://pve.proxmox.com/wiki/Shrink_Qcow2_Disk_Files#Linux_Guest_Preparation
 
  • Like
Reactions: bumann