LXC LVM-thin discard fstrim

TECOB

Member
Apr 28, 2017
15
0
21
49
Hi,

We are running a server with several LXC containers. This server data pool is under LVM-thin and as time goes by, disk space keeps on increasing. Even if files are deleted on LXC containers, data % on host stays the same.

We have seen that running fstrim on LXC containers freed space on Host and so, data percentage was reduced.

In /etc/lvm/lvm.conf issue_discards is enabled (1)
Running
$ lvs -o+discards pve/data
shows discards option as 'passdown'

Have we missed a configuration? Isn't it supposed to reduce space automatically when files are deteled on LXC containers?
Should we run fstrim service on LXC containers periodically to free space?

Have someone met this situation? How could we solve that?

Regards,

Jordi.
 
The LCX root volumes are mounted without the ext4 discard flag, so I guess it's not automated. It would be really useful to be able to set the mount options or at least discard.

I've put together this small scritp for my test server to aid in a weekly fstrim task. Maybe it helps someone...

Code:
#!/bin/bash

# static list of volumes to trim
TRIMVOLS="/"

FSTRIM=/sbin/fstrim

# trim static list
for i in $TRIMVOLS; do
  $FSTRIM -v $i 2>&1 | logger -t "fstrim-cron[$$]"
done

# trim all LXC containers
for i in $(pct list | awk '/^[0-9]/ {print $1}'); do
  $FSTRIM -v /proc/$(lxc-info -n $i -p | awk '{print $2}')/root 2>&1
done | logger -t "fstrim-cron[$$]"
 

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!