Can't get fstrim.timer to run

It apparently is loaded, yet inactive.

> systemctl list-timers --all
>     NEXT                         LEFT                LAST                         PASSED       UNIT                         ACTIVATES                     
>     Mon 2020-09-07 00:00:00 EEST 8h left             Sun 2020-09-06 06:51:21 EEST 8h ago       logrotate.timer              logrotate.service             
>     Mon 2020-09-07 00:00:00 EEST 8h left             Sun 2020-09-06 06:51:21 EEST 8h ago       man-db.timer                 man-db.service                
>     Mon 2020-09-07 00:00:00 EEST 8h left             Sun 2020-09-06 06:51:21 EEST 8h ago       shadow.timer                 shadow.service                
>     Mon 2020-09-07 00:23:52 EEST 9h left             n/a                          n/a          fstrim.timer                 fstrim.service                
>     Mon 2020-09-07 10:20:35 EEST 19h left            Sun 2020-09-06 10:20:35 EEST 4h 58min ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
>     Thu 2020-09-10 12:31:21 EEST 3 days left         Thu 2020-09-03 13:18:13 EEST 3 days ago   pamac-mirrorlist.timer       pamac-mirrorlist.service      
>     Sat 2020-10-03 15:00:00 EEST 3 weeks 5 days left Sat 2020-09-05 15:00:26 EEST 24h ago      pamac-cleancache.timer       pamac-cleancache.service

However, if I do sudo systemctl status fstream.timer I get Unit fstream.timer could not be found., same for systemctl start fstrim.service

FWIW, I installed this via Architect and I initally chose discard as a mount option, but have since learned it quickly degrades the SSD, so I removed it and did sudo systemctl enable fstrim.timer which appeared to have worked.

What am I missing?

1 Like

use fstrim.timer and you are OK. It should give you an output like this:

[xxx@xxx ~]$ systemctl status fstrim.timer
â—Ź fstrim.timer - Discard unused blocks once a week
Loaded: loaded (/usr/lib/systemd/system/fstrim.timer; enabled; vendor preset: disabled)
Active: active (waiting) since Sun 2020-09-06 14:12:27 CEST; 35min ago
Trigger: Mon 2020-09-07 01:21:00 CEST; 10h left
Triggers: â—Ź fstrim.service
Docs: man:fstrim

Sep 06 14:12:27 xxx systemd[1]: Started Discard unused blocks once a week.

You had the syntax wrong. It’s not a service ─ i.e. a daemon ─ but a timer, the systemd equivalent of a cron script. :wink:

The correct syntax is… :arrow_down:

sudo systemctl enable fstrim.timer --now

:wink:

1 Like

This is exactly what I did, check my original post, I mention this at the end.

I did it again, just to be sure. It appeared to go through just fine, yet when I do sudo systemctl status fstream.timer I get this Unit fstream.timer could not be found.

That’s because you made a typo. You typed “fstream” instead of “fstrim”.

In addition to that, you cannot get the status for fstrim.service, because fstrim.timer is not a daemon; it’s a script that gets executed at timed intervals and that calls fstrim.service for what it needs to do.

2 Likes

The command is certainly correct. But the option ---now is IMHO not really needed for fstrim as it’s causing an immediate trim. Since the trim is timed to be executed once a week it does not matter when the first trim happens, so why doing it immediately? Hope you don’t mind this comment… :sweat_smile:

Was my post so unclear?

1 Like

No, if you simply enable it, then the timer will be started upon the next boot, but then it won’t be running yet in the current runtime environment. Hence the --now. It adds the timer to the list of timers that must be started upon the next boot, and it also starts the timer in the running environment. It will however not run fstrim right away.

1 Like

OK, thanks for the clarification, that makes sense, especially as some users not boot frequently. :+1:

1 Like

In that case, if the system was not running at the time that the timer would execute the fstrim operation, the fstrim will be executed upon the next boot. :wink:

1 Like

Oh, my. I feel stupid now.

1 Like

Hey man, don’t worry! :beer:

:arrow_down:

To err is human

(And to arr is pirate! :pirate_flag: :rofl: )

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.