For all distributions a suitable filesystem must be used that supports this functionality. For example 'ext4'.


Fedora 21+

In Fedora support is enabled by running the below commands...
    systemctl enable fstrim.timer
    systemctl start fstrim.timer

CentOS 7+

In CentOS 7 support is enabled by running the below commands...
    systemctl enable fstrim.timer
    systemctl start fstrim.timer

Ubuntu 16.04+

There is no need to do anything here. Its enabled by default in /etc/cron.weekly/fstrim.


Debian 8 & 9

In Debian support is enabled by running the below commands...
    cp /usr/share/doc/util-linux/examples/fstrim.service /etc/systemd/system/
    cp /usr/share/doc/util-linux/examples/fstrim.timer /etc/systemd/system/
    systemctl enable fstrim.timer
    systemctl start fstrim.timer

OpenSuse 13+

In OpenSuse 13 support is enabled by running the below commands...
    systemctl enable fstrim.timer
    systemctl start fstrim.timer

CentOS 6

CentOS 6 doesn't have systemd support for fstrim, but it can easily be setup with a cronjob. Run the following command to edit your crontab...
    cron -e

In the editor which pops up, create a weekly cron, save and exit...

    @weekly /sbin/fstrim /