Deleting files does not reduce local-lvm capacity.

Fukuringa

New Member
Jan 27, 2025
5
0
1
First of all, I am Japanese and I use a translation tool called Deepl.
Therefore, some sentences may not be correct. If this is the case, please do not hesitate to let me know.

Also, this is my first time using such a forum, so I apologize if the forum posting instructions are incorrect
.

-----

Uploading and deleting files on ubuntu does not reduce space in local-lvm.
The same goes for deleting files and waiting an hour.

The only way to reduce this is to delete the CT itself.

Can the reduction in space be reflected without deleting the CT itself?

Please watch the video for more information.
https://youtu.be/Aq_VMyI-KYU
 
Last edited:
lvm-thin is block storage for LXC and VM virtual disks, it does not present itself as a traditional filesystem.

(translation follows)
lvm-thinは、LXCおよびVM仮想ディスク用のブロックストレージであり、従来のファイルシステムとして表示されません。
 
  • Like
Reactions: GoXLd
lvm-thin is block storage for LXC and VM virtual disks, it does not present itself as a traditional filesystem.

(translation follows)
lvm-thinは、LXCおよびVM仮想ディスク用のブロックストレージであり、従来のファイルシステムとして表示されません。
I am trying to create a simple backup server on Ubuntu Server that automatically uploads and deletes files on a regular basis. However, the capacity of the local-lvm does not decrease even after deletion, so eventually the capacity will fill up and the server will stop.

In the past, the capacity of deleted files on Proxmox 7.3 was not reflected, the capacity became full and the server stopped.
The Proxmox version currently in use is 8.3.

How can I solve this problem?
 
Hey, As Kingneutron already say, the issue is caused by how local-lvm and thin provisioning in LVM work. Deleted files free space in the filesystem but not on the LVM level because unused blocks aren't automatically released.

Solution:​

Enable TRIM in the container:
Code:
fstrim -v /
Enable DISCARD in LVM: In /etc/lvm/lvm.conf, set
Code:
issue_discards = 1
Use a TRIM-compatible filesystem: Ensure the container uses ext4 or xfs.
Automate TRIM - Add to cron:
Code:
0 3 * * * root fstrim -v /
This will ensure freed space is reclaimed in local-lvm.
 
Last edited:
  • Like
Reactions: Kingneutron
Hey, As Kingneutron already say, the issue is caused by how local-lvm and thin provisioning in LVM work. Deleted files free space in the filesystem but not on the LVM level because unused blocks aren't automatically released.

Solution:​

Enable TRIM in the container:Run:

Code:
fstrim -v /
Enable DISCARD in LVM:In /etc/lvm/lvm.conf, set:
Code:
issue_discards = 1
Use a TRIM-compatible filesystem: Ensure the container uses ext4 or xfs.
Automate TRIM:Add to cron:
Code:
0 3 * * * root fstrim -v /
This will ensure freed space is reclaimed in local-lvm.
Thank you.
I'm trying them out as soon as possible now.
 
Hey, As Kingneutron already say, the issue is caused by how local-lvm and thin provisioning in LVM work. Deleted files free space in the filesystem but not on the LVM level because unused blocks aren't automatically released.

Solution:​

Enable TRIM in the container:
Code:
fstrim -v /
Enable DISCARD in LVM: In /etc/lvm/lvm.conf, set
Code:
issue_discards = 1
Use a TRIM-compatible filesystem: Ensure the container uses ext4 or xfs.
Automate TRIM - Add to cron:
Code:
0 3 * * * root fstrim -v /
This will ensure freed space is reclaimed in local-lvm.
I just tried it, I set issue_discards = 1 and lvm2-monitor was running, so I restarted that too just to be sure and tried it, but only a few MB disappeared and about 30 GB that I uploaded and deleted as a test were still shown in local-lvm and had not been reduced. It was not reduced.

In /etc/lvm/lvm.conf, set issue_discards in the devices item from 0 to 1 and run systemctl restart lvm2-monitor. I then ran fstrim -v / in a proxmox shell.

If I am wrong, please let me know.
 

Attachments

  • スクリーンショット 2025-01-28 052645.png
    スクリーンショット 2025-01-28 052645.png
    10.4 KB · Views: 6
  • スクリーンショット 2025-01-28 052659.png
    スクリーンショット 2025-01-28 052659.png
    1.4 KB · Views: 6
Verify that your disk and storage device fully support TRIM.
lsblk --discard

1738018568945.png

If DISC-GRAN or DISC-MAX is 0, TRIM is not supported, and you cannot fully reclaim space.

Update: I'm now asking the experts: I was wondering, if TRIM is not working or supported, would it make sense to fill the free space with zeroes and then try running fstrim -v again?
 
Last edited:
Verify that your disk and storage device fully support TRIM.
lsblk --discard

View attachment 81487

If DISC-GRAN or DISC-MAX is 0, TRIM is not supported, and you cannot fully reclaim space.

Update: I'm now asking the experts: I was wondering, if TRIM is not working or supported, would it make sense to fill the free space with zeroes and then try running fstrim -v again?

On checking, some were non-zero.
sdb and sr0 were zero.
 

Attachments

  • スクリーンショット 2025-01-28 152501.png
    スクリーンショット 2025-01-28 152501.png
    17.5 KB · Views: 4