Files are not deleted from local-lvm

SimPos

New Member
Aug 14, 2024
6
0
1
Good morning, my English is poor, I'll try to explain my question

I'm using ProxMox, and I created a VM for storage, everything is working, but there's a problem, after deleting files from the Storage VM the local-lvm volume is not reduced, I put a 3GB ISO, there were 6GB occupied, there were 9GB in the local-lvm, then I deleted the 3GB ISO, and the local-lvm still has 9GB

It seems that some kind of temporary file remains, how do I make lvm reduce the size and behave with deletions correctly?
 
Did you enable "Discard" for the VM disk? If yes, did the VM already discard/trim?
 
it's expected as local-lvm is only for VM storage.
iso are stored in "local"
I don't think I expressed myself correctly, the ISO I placed was just a file for storage, it was a Windows ISO, it could be any file, which after placed it fills the LVM, but after being deleted it does not return to its size, so the storage will be compromised.
 
In the PVE webUI, go to the hardware tab of every VM, edit each virtual disk there and check the "Discard" checkbox. In addition you need to tell each guestOS inside your VM to actually trim/discard. How to do this completely depends on the guestOS your VM is using. In a Linux guestOS you could mount a ext4/xfs filesystem with the "discard" mount option or set up some cron to run a daily/weekly "fstrim -a". On a Windows guestOS you will have to tell Windows to regularly optimize the (virtual) disks.
 
Last edited:
In the PVE webUI, go to the hardware tab of every VM, edit each virtual disk there and check the "Discard" checkbox. In addition you need to tell each guestOS inside your VM to actually trim/discard. How to do this completely depends on the guestOS your VM is using. In a Linux guestOS you could mount a ext4/xfs filesystem with the "discard" mount option or set up some cron to run a daily/weekly "fstrim -a". On a Windows guestOS you will have to tell Windows to regularly optimize the (virtual) disks.

Hello, I found the option, I was able to activate it, the LVM keeps the same volume, will it only be applied in the next deletions? Or do I need to redo the VM?

How could I do this procedure on a guest? At the moment I tested it on an Ubuntu VM, I would need it to have the default behavior, each time it was deleted the LVM would return with a free volume, otherwise from that moment the volume will just keep swelling

Edit: With Discard active, I tried to put another large file over the network, naturally it increased in size in the LVM, I deleted it and it remained the same size, if I put another file the LVM will saturate and cause problems in the VM
 
Last edited:
It sounds like you're not addressing a larger problem, which is you're running with too small of a storage space for your VMs. Consider upgrading to larger disks so you have more free space - remember, you also need space for snapshots.
 
How could I do this procedure on a guest? At the moment I tested it on an Ubuntu VM, I would need it to have the default behavior, each time it was deleted the LVM would return with a free volume, otherwise from that moment the volume will just keep swelling
Like already said, ticking the "discard" checkbox alone won't help. You will have to configure your Ubuntu to trim free space. You will have to edit your Ubuntus fstab and mount filesystems with the discard option or create a systemd service/cron job to run a "fstrim -a". Using the latter it won'T free up space immediately but only when that service/cron runs.
 

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!