Tutorials
goetia
Software
0x53.net

SSD trimming

Modern SSD's need to be informed if a block is not used by the OS anymore and can be discarded for reuse and performance as well as lifetime optimization.

This can either be done automatically on every unlink() call by using the -o discard mount option, or periodically through a service calling fstrim.

Since the former often incurs a performance penalty, a service is used most of the time. The following will explain how to set up such a service.

A periodic trim service

Create the following longrun source directory in the src/maintenance/trim-srv subdirectory of the system supervision tree.

shibari-udp-ipv4-srv
├── dependencies.d
│   └── mount         # empty/arbitrary
├── producer-for      # trim-log
├── run               # see below
└── type              # longrun
			

with the following run script:

#!/bin/execlineb -P

fdmove -c 2 1

snooze
	-H 20
	-M 30
	fstrim -a
			

This example runs fstrim on all drives every day at by utilizing snooze. which can of course be freely changed. See the documentation of snooze.