Page MenuHomeVyOS Platform

fstrim systemd timer/unit does effectively nothing
Closed, ResolvedPublicBUG

Description

Hi,

I'm not running the latest rolling release available but I haven't found any recent fixed issue concerning this report so today's image is likely affected.

VyOS runs periodically fstrim.timer which in turn executes fstrim.service. I believe this is just inherited from Debian as-is and shipped unmodified. The systemd unit runs:

ExecStart=/sbin/fstrim --listed-in /etc/fstab:/proc/self/mountinfo --verbose --quiet-unsupported

Which feeds information about the filesystems to trim via --listed-in.

This is an except from fstrim(8):

-I, --listed-in list
     Specifies a colon-separated list of files in fstab or kernel mountinfo
     format.  All  missing or empty files are silently ignored. The evalua‐
     tion of the list stops after first non-empty file.

Hence, in VyOS's case, /etc/fstab is only considered (and /proc/self/mountinfo unfortunately ignored) as the first element (/etc/fstab) is non-empty.

vyos@vyos01:~$ cat /etc/fstab 
# UNCONFIGURED FSTAB FOR BASE SYSTEM
overlay / overlay rw 0 0
tmpfs /tmp tmpfs nosuid,nodev 0 0
tmpfs /var/tmp tmpfs nosuid,nodev 0 0

This issue here is that fstrim will ignore /as it's an overlay FS and no further action will be taken. However, what we'd actually want to trim is the actual filesystem behind: /usr/lib/live/mount/persistence

In fact, when running fstrim manually passing only /proc/self/mountinfo then the desired trim actually happens, see:

# Executing the trim as the systemd unit would do:
vyos@vyos01:~$ sudo fstrim --listed-in /etc/fstab:/proc/self/mountinfo --verbose
# Nothing happens!!
# Executing passing only /proc/self/mountinfo, where the actual (and target for trimming) FS is listed
vyos@vyos01:~$ sudo fstrim --listed-in /proc/self/mountinfo --verbose
/usr/lib/live/mount/persistence: 15.7 GiB (16808431616 bytes) trimmed on /dev/sda3
# Voila!

To fix this issue I'd suggest to for instance patch the systemd unit to only consume information from /usr/lib/live/mount/persistence

Details

Version
2026.03.01-0029-rolling
Is it a breaking change?
Perfectly compatible
Issue type
Bug (incorrect behavior)

Event Timeline

Forgot to mention that lacking proper FS trimming has a very negative impact when running VyOS virtualised and having the filesystem sitting on a thin provisioned volume, like for instance LVM thin. The absence of discard commands coming from the virtual node does not allow the cleaning of unused blocks.

The unit could be patched with a drop-in systemd override.

Bug reproduced on image 2026.07.21-1151-rolling and proposed patch tested.

On Stream 2026.03 (runned virtualized in Proxmox, the virtual drive is configured with discard and ssd in VM-guest settings i Proxmox and the host drive is using ZFS) it do seem to be working when running with sudo but not without sudo:

vyos@vyos:~$ fstrim -v -a
vyos@vyos:~$ sudo fstrim -v -a
/usr/lib/live/mount/persistence: 70.8 GiB (76040658944 bytes) trimmed on /dev/sda3
vyos@vyos:~$

Output of lsblk -a:

vyos@vyos:~$ lsblk -a
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0    7:0    0 472.1M  1 loop /usr/lib/live/mount/rootfs/2026.03.squashfs
loop1    7:1    0     0B  0 loop 
loop2    7:2    0     0B  0 loop 
loop3    7:3    0     0B  0 loop 
loop4    7:4    0     0B  0 loop 
loop5    7:5    0     0B  0 loop 
loop6    7:6    0     0B  0 loop 
loop7    7:7    0     0B  0 loop 
sda      8:0    0    80G  0 disk 
├─sda1   8:1    0     1M  0 part 
├─sda2   8:2    0   256M  0 part 
└─sda3   8:3    0  79.7G  0 part /usr/lib/live/mount/persistence/container/storage/overlay
                                 /usr/lib/live/mount/persistence/boot/2026.03/grub
                                 /boot/grub
                                 /boot
                                 /usr/lib/live/mount/persistence
sr0     11:0    1  1024M  0 rom
Viacheslav changed the task status from Open to In progress.Jul 28 2026, 11:07 AM
Viacheslav assigned this task to nacho.
Viacheslav triaged this task as Normal priority.
Viacheslav moved this task from Need Triage to Completed on the VyOS Rolling board.

Thanks for looking into this and merging the patch.