Opened 6 months ago

Last modified 4 weeks ago

#29846 new defect

fstrim script makes noises on some servers

Reported by: anarcat Owned by: tpa
Priority: Low Milestone:
Component: Internal Services/Tor Sysadmin Team Version:
Severity: Minor Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


we get this nightly since bungei was installed:

Date: Thu, 21 Mar 2019 06:25:03 +0000

fstrim: /srv/backups/pg: the discard operation is not supported
fstrim: /srv/backups/bacula: the discard operation is not supported

this is from the following script deployed through puppet:


# by weasel

if tty > /dev/null; then

awk '$9 ~ "^(ext4|xfs)$" && $4 == "/" {print $3, $5}' /proc/self/mountinfo | while read mm mountpoint; do
  [ -e "$path" ] || continue
  path="$(readlink -f "$path")"

  while : ; do
    if [ -e "$qi" ]; then
      [ "$(cat "$qi")" -gt "0" ] && fstrim $verbose "$mountpoint"
    # else try the parent
    path="$(readlink -f "$path/..")"
    # as long as it's a device
    [ -e "$path/dev" ] || break

I can confirm the mapped device cannot be "trimmed":

root@bungei:/home/anarcat# fstrim -v /srv/backups/pg
fstrim: /srv/backups/pg: the discard operation is not supported

I'm unsure why that is the case. I suspect it might be a matter of adding the issue_discards option to lvm.conf, but I'm not sure. I also note that the discard option is not present in crypptab either.

In the Debian wiki SSDOptimization page, they mention a fstrim systemd service (not required in Buster, apparently) that supposedly takes care of that work for us. It does, however, only the following command:

fstrim -av

... which doesn't seem to do anything here. It also doesn't silence the warnings from the script, so I'm not sure it's *doing* anything.

In any case, I welcome advice on how to deal with that one warning.

Child Tickets

Change History (1)

comment:1 Changed 4 weeks ago by weasel

since bungei has rotating disks, that script probably shouldn't run there anyhow. Thus, the fact that fstrim -av doesn't do anything is not surprising. (If bungei did have SSDs, the crypttab should have the discard option.)

Regardless, we probably should replace that script with using the fstrim service and its timer shipped by util-linux -- /usr/share/doc/util-linux/examples/fstrim.{service,timer}.

Note: See TracTickets for help on using tickets.