get sparse space back from once filled HD?

fips

Renowned Member
May 5, 2014
175
9
83
Hi,

I have a CT HD with 100G, it was once filled up to 90%, now its just filled with 14% of data.
When I backup the CT now, it takes a lot of time, in the begining it was faster.

Can I somehow clean that HD or somehow get teh sparse space back?
 
As far as I am aware the easiest way is to use the new trim features to reclaim space.

Assuming you are using ZFS/LVM storage and have discard enabled. You can log into the guest and run the following.

~# fstrim -av
/: 5.8 GiB (6173188096 bytes) trimmed

Once you have done this, the backend storage will know it can reclaim the space and shrink the backend storage.

If you are using qcow images, you will have to read the following. https://pve.proxmox.com/wiki/Shrink_Qcow2_Disk_Files#Shrink_the_Disk_File
 
  • Like
Reactions: fips

Perfect, in that case, if you enable discard and run `fstrim -av` on the guest. You should reclaim the space.

If you need to reclaim more space, you will need to fill the unused space on the guest with 0's and then run fstrim. The only requirement is that the guest is not encrypted with something like LUKS. Otherwise, I don't think the 0 fill will work.

I don't know if your guest is Linux or Windows, but if you want to reclaim as much as possible you will need to zerofill the guest disk using a such as those described in here.