If you want the reasonably easy way to set the whole thing up, I followed the instructions from :
Easy tips, tweaks and tricks for Linux Mint and Ubuntu, both for beginners and for advanced users. Complete starter's guide with simple how-to's.
easylinuxtipsproject.blogspot.com
quite some time ago. It works. How do I know it works?....by copy/pasting in this:
journalctl | grep fstrim.service
which produces:
brian@brian-desktop:~$ journalctl | grep fstrim.service
Feb 17 00:04:42 brian-desktop systemd[1]: Starting fstrim.service - Discard unused blocks on filesystems from /etc/fstab...
Feb 17 00:05:10 brian-desktop systemd[1]: fstrim.service: Deactivated successfully.
Feb 17 00:05:10 brian-desktop systemd[1]: Finished fstrim.service - Discard unused blocks on filesystems from /etc/fstab.
Feb 24 04:54:50 brian-desktop systemd[1]: Starting fstrim.service - Discard unused blocks on filesystems from /etc/fstab...
Feb 24 04:55:20 brian-desktop systemd[1]: fstrim.service: Deactivated successfully.
Feb 24 04:55:20 brian-desktop systemd[1]: Finished fstrim.service - Discard unused blocks on filesystems from /etc/fstab.
brian@brian-desktop:~$
I initially had weekly trimming in place, but decided later that weekly was not enough....mainly due to the amount of use my pc gets.....so I switched it to Daily
You can use the following blurb anyway...regardless if you have set it up before or not.
You can switch your system to automatic
daily trimming as follows:
a.
Copy/paste the following command line into the terminal, in order to create a new folder:
sudo mkdir -v /etc/systemd/system/fstrim.timer.d
Press Enter. Type your password when prompted.
In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.
b.
Copy/paste the following command line into the terminal, in order to create a new file in that new folder:
sudo touch /etc/systemd/system/fstrim.timer.d/override.conf
Press Enter.
c.
Copy/paste the following command line into the terminal, in order to edit the new file:
xed admin:///etc/systemd/system/fstrim.timer.d/override.conf
(
Note: The three consecutive slashes aren't a typo, but intentional! For Ubuntu: type
gedit instead of
xed.)
Press Enter.
d. Now
copy/paste this blue text into that empty text document:
[Timer]
OnCalendar=
OnCalendar=daily
Note: The double entry for OnCalendar is no mistake but intentional!
Save the modified file and close it.
e. Reboot your computer.
f. Confirm that you've successfully edited trim's configuration by executing this terminal command:
systemctl cat fstrim.timer
Your output should look approximately like this:
# /lib/systemd/system/fstrim.timer
[Unit]
Description=Discard unused blocks once a week
Documentation=man:fstrim
ConditionVirtualization=!container
[Timer]
OnCalendar=weekly
AccuracySec=1h
Persistent=true
[Install]
WantedBy=timers.target
# /etc/systemd/system/fstrim.timer.d/override.conf
[Timer]
OnCalendar=
OnCalendar=daily
Let's take a closer look at this output. The first part shows the default setting (weekly), the second part shows the overriding setting that you've applied. That overriding setting contains two elements: first the existing OnCalendar setting (weekly) is being deleted by specifying nothing after the
= sign, and then a new OnCalendar setting is being applied (daily).
If you ever want to check whether fstrim has actually happened, and when it happened, you can use this terminal command:
journalctl | grep fstrim.service