is it possible to auto trim for lxc disks?

alexskysilk

Distinguished Member
Oct 16, 2015
1,848
378
153
Chatsworth, CA
www.skysilk.com
I have a cluster that has relatively heavy IO and consequently free space on the ceph storage is constantly constrained. I'm finding myself performing fstrim on a more and more frequent interval. Is there a way to auto trim a disk for an lxc container?
 
hi,

you can use `pct fstrim CTID` to trim the disk of a single CT. with a bash for-loop and a cronjob, you should be able to run it for all CTs.
 
  • Like
Reactions: nico400 and guletz
if there was possible to do it automatically at mount.

you can take a look at the hookscripts/snippet feature.

from PVE Admin Guide:

Code:
11.6.7. Hookscripts
You can add a hook script to CTs with the config property hookscript.
pct set 100 -hookscript local:snippets/hookscript.pl
It will be called during various phases of the guests lifetime. For an example and documentation see the example script under /usr/share/pve-docs/examples/guest-example-hookscript.pl.
 
how about running it post-start?
 
well, that would run the script once and will not impact any writes following. my thought was some kind of autodiscard but it doesnt appear that this is possible. Thanks for your thoughts :) I will continue to tweak the cron schedule.
 

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!