3

I want to do what follows:

  1. set (via systemctl) a trim timer which would trim more than once a week but less than daily. Say every three days.

  2. I want to be sure that if the system is turned off or sleeping what the scheduled trim should be executed, it will be executed at the next awakening/boot.

How can I do that?

MadHatter
  • 481
  • 5
  • 17
  • 27

1 Answers1

2

Not a perfect solution, but as a stop-gap, you can manually trim on-demand via a command like sudo /sbin/fstrim -av See below before running this; you want to make sure you get the right command!

systemctl cat fstrim.service will show you the fstrim service file.

Look at the bottom and see what's being executed. You'll see this after the line ExecStart=. It will probably, for Ubuntu 18.04, be calling /sbin/fstrim -av.

With this in mind, run sudo /sbin/fstrim -av and you'll see something like

/boot: 0 B (0 bytes) trimmed
/: 6 GiB (6384705536 bytes) trimmed

Boom, trimmed!

And, yes, it doesn't ask the question you're really after, which is the same question I have after seeing this question. I'll look into this myself on my laptop and post back here--it'll help us both!

Chris
  • 21
  • 4