pct fstrim <CT_ID> ignore /mnt ?

sshanee

New Member
Oct 6, 2019
8
4
3
38
any way to get the pct fstrim command to ignore the /mnt directory or mountpoints in the LXC? i get an error on all LXC with ZFS mountpoints:

fstrim: /var/lib/lxc/121/rootfs/mnt/Media: the discard operation is not supported
command 'fstrim -v /var/lib/lxc/121/rootfs/mnt/Media' failed: exit code 1
 

oguz

Proxmox Retired Staff
Retired Staff
Nov 19, 2018
5,207
695
118
Thank you so much! Is pct fstrim the only way to trim the container? I tried running fstrim from inside the debian 10 lxc and it doesnt seem to do anything
what pct fstrim does is basically pct mount CTID && fstrim -av

so if you wanted to trim all the containers you could do something like this as well: pct list | awk -F " " '{print $1}' | while read ct; do pct mount $ct; done; fstrim -av

don't forget to unmount the containers with pct unmount CTID
 

comfreak

Member
May 20, 2020
45
10
13
33
Guys, the pct fstrim does not work for me. if i execute it directly via pct fstrim 201 I get the following error:

root@proxmox:~# pct fstrim 201
fstrim: /var/lib/lxc/201/rootfs/: the discard operation is not supported
command 'fstrim -v /var/lib/lxc/201/rootfs/' failed: exit code 1

if I do it the manual way, the container will not be shown as mounted volume:

pct mount 201
mount | grep /var/lib/lxc/201/rootfs/ -> <empty>

so fstrim -av does not apply to the container

root@proxmox:~# fstrim -av
/boot/efi: 510.7 MiB (535486464 bytes) trimmed on /dev/nvme0n1p2
/: 3.3 GiB (3587186688 bytes) trimmed on /dev/mapper/pve-root


What do I am missing here?
 

oguz

Proxmox Retired Staff
Retired Staff
Nov 19, 2018
5,207
695
118
pct mount 201
mount | grep /var/lib/lxc/201/rootfs/ -> <empty>
can you try pct mount 201 and then mount | grep lxc ?

if mounting doesnt work please post the container configuration: pct config CTID
 

comfreak

Member
May 20, 2020
45
10
13
33
yeah, seems my grep was wrong:

root@proxmox:~# mount | grep lxc
lxcfs on /var/lib/lxcfs type fuse.lxcfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)

root@proxmox:~# pct mount 201
mounted CT 201 in '/var/lib/lxc/201/rootfs'

root@proxmox:~# mount | grep lxc
lxcfs on /var/lib/lxcfs type fuse.lxcfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)
local-VMs/subvol-201-disk-0 on /var/lib/lxc/201/rootfs type zfs (rw,xattr,posixacl)
data1 on /var/lib/lxc/201/rootfs/mnt/data1 type zfs (rw,noatime,xattr,noacl)
data2 on /var/lib/lxc/201/rootfs/mnt/data2 type zfs (rw,xattr,noacl)

But fstrim -av onlytrims my nvme-ssd:

root@proxmox:~# fstrim -av
/boot/efi: 510.7 MiB (535486464 bytes) trimmed on /dev/nvme0n1p2
/: 8.8 GiB (9432932352 bytes) trimmed on /dev/mapper/pve-root

If I specify it directly:

root@proxmox:~# fstrim -v /var/lib/lxc/201/rootfs
fstrim: /var/lib/lxc/201/rootfs: the discard operation is not supported
 

oguz

Proxmox Retired Staff
Retired Staff
Nov 19, 2018
5,207
695
118
looks like your container is on ZFS, to enable trim on ZFS: zpool set autotrim=on $YOURPOOLNAME should work
 

comfreak

Member
May 20, 2020
45
10
13
33
Oh okay, so I do not need a manual pct fstrim <id> as ZFS handles it for me automaticly?
 

oguz

Proxmox Retired Staff
Retired Staff
Nov 19, 2018
5,207
695
118
yes if you set the option it should be automatically trimmed at regular intervals
 

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 your own in 60 seconds.

Buy now!