fstrim script makes noises on some servers
we get this nightly since bungei was installed: ``` To: root@bungei.torproject.org Date: Thu, 21 Mar 2019 06:25:03 +0000 /etc/cron.daily/puppet-trim-fs: 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 verbose="-v" else verbose="" fi awk '$9 ~ "^(ext4|xfs)$" && $4 == "/" {print $3, $5}' /proc/self/mountinfo | while read mm mountpoint; do path="/sys/dev/block/$mm" [ -e "$path" ] || continue path="$(readlink -f "$path")" while : ; do qi="$path/queue/discard_max_bytes" if [ -e "$qi" ]; then [ "$(cat "$qi")" -gt "0" ] && fstrim $verbose "$mountpoint" break fi # else try the parent path="$(readlink -f "$path/..")" # as long as it's a device [ -e "$path/dev" ] || break done done ``` 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](https://wiki.debian.org/SSDOptimization), 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.
issue