Trim
- chrispop99
- Global Moderator
- Posts: 3323
- Joined: Tue Jan 27, 2009 2:07 pm
Re: Trim
TRIM is run automatically once a week.
The information is in section 3.1.5 of the User Manual.
Chris
The information is in section 3.1.5 of the User Manual.
Chris
MX Facebook Group Administrator.
Home-built desktop - Core i5 9400, 970 EVO Plus, 8GB
DELL XPS 15
Lots of test machines
Home-built desktop - Core i5 9400, 970 EVO Plus, 8GB
DELL XPS 15
Lots of test machines
Re: Trim
The weekly fstrim on mounted partitions has long been set up in MX-Linux.
It would be better if you post QSI “Quick System Info” and perhaps the contents of /etc/fstab.
We had discard operations enabled on mount for a while, which was recently reversed due to possible negative effects on the lifespan of low-quality SSDs.
Re: Trim
The negative effects of the discard option can even be seen on recent SSDs as a major file system performance hit. It also is known for not playing nice with some firmware such as that of Samsung SSDs.
A good way to find out if your device has TRIM support:
If any of the DISC-GRAN or DISC-MAX columns are zero, the corresponding device does not support TRIM. Some HDDs also support TRIM.
A good way to find out if your device has TRIM support:
Code: Select all
lsblk -o +DISC-GRAN,DISC-MAX
Re: Trim
1. What does it mean: "Trim is run automatically once a week"? It means, if I keep the laptop open for at least a week, Trim will run once, but if I shutdown the system everyday, Trim will not run anymore, because it is considered that the system worked just a few hours/day, and the counting starts again at every daily new startup?
2. I am interested to know when exactly will run Trim, at least in what day of the week. Is it possible to know, or Trim will run completely random?
3. If I rename the file /etc/cron.weekly/fstrim-mx in fstrim-mx.old, the weekly trim action will be disabled?
4. If there is no trim.log file in /var/log/ directory, that means no trim was performed ever on my SSDs?
I think these are general enough questions, not specific to my system so, unless you want to know my specific laptop footprint, no QSI is needed for a response. (I run MX Linux XFCE 23.5 ahs x64 from a USB stick with persistence and my Trim seems to be enabled, conform the above lsblk command, but I don't have a trim.log file)
Thank you.
2. I am interested to know when exactly will run Trim, at least in what day of the week. Is it possible to know, or Trim will run completely random?
3. If I rename the file /etc/cron.weekly/fstrim-mx in fstrim-mx.old, the weekly trim action will be disabled?
4. If there is no trim.log file in /var/log/ directory, that means no trim was performed ever on my SSDs?
I think these are general enough questions, not specific to my system so, unless you want to know my specific laptop footprint, no QSI is needed for a response. (I run MX Linux XFCE 23.5 ahs x64 from a USB stick with persistence and my Trim seems to be enabled, conform the above lsblk command, but I don't have a trim.log file)
Thank you.
- DukeComposed
- Posts: 1283
- Joined: Thu Mar 16, 2023 1:57 pm
Re: Trim
"Trim is run automatically once a week" means that trim is run automatically once a week. As you've already demonstrated, you know this is scheduled by means of a file in /etc/cron.weekly. The cron daemon decides when to run this and it's generally pretty good about being able to count to 7 days.
That doesn't mean it's still going to work as intended if you try to outthink it and start playing tricks like shutting your machine down. cron is an old piece of scheduling software and it's fairly reliable, but it's not psychic and it doesn't have magic powers.
Then run trim at a precise day and time of your choosing. You know what the fstrim-mx script does and where it lives. You can move it to a different location and call it from a new crontab, possibly in /etc/cron.d, without causing any trouble. "man 5 crontab" will be useful here and while DuckDuckGo doesn't seem to do crontabs in its search engine anymore, there are still other useful tools online that can help.
- dolphin_oracle
- Developer
- Posts: 22002
- Joined: Sun Dec 16, 2007 12:17 pm
Re: Trim
anancron runs cron jobs in the hourly, weekly, daily, and monthly schedules based on time stamps from the last run, stored in /var/spool/anacron. if a time stamp doesn't exist, or if a date/time is passed (say, while a PC is off), the jobs will be run within so many minutes of service startup/boot, 5 for daily, 10 for weekly, if I remember correctly.
running missed jobs is an advantage of anacron.
running missed jobs is an advantage of anacron.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.
Re: Trim
Thank you for reply, man.DukeComposed wrote: ↑Wed Apr 09, 2025 8:56 am"Trim is run automatically once a week" means that trim is run automatically once a week. As you've already demonstrated, you know this is scheduled by means of a file in /etc/cron.weekly. The cron daemon decides when to run this and it's generally pretty good about being able to count to 7 days.
That doesn't mean it's still going to work as intended if you try to outthink it and start playing tricks like shutting your machine down. cron is an old piece of scheduling software and it's fairly reliable, but it's not psychic and it doesn't have magic powers.
Then run trim at a precise day and time of your choosing. You know what the fstrim-mx script does and where it lives. You can move it to a different location and call it from a new crontab, possibly in /etc/cron.d, without causing any trouble. "man 5 crontab" will be useful here and while DuckDuckGo doesn't seem to do crontabs in its search engine anymore, there are still other useful tools online that can help.
I'm afraid I didn't understand from your response at point 1. if Trim will run once a week, even if I work a few hours a day and then shutdown the machine. I understood though the ironies, you are very good at (I don't "outthink" anything, it's just the way I use my laptop). The question was if the cron daemon that runs weekly the fstrim-mx script will restart the count of the week every time I restart or power on my system, because if this is the case, than the Trim will never take place, the way I use my system (as a desktop, not as a server), which is maybe why I don't have a trim.log file. I just wanted a confirmation or refutation from a more knowledgeable linux user than me.
From your second answer, I will take your suggestion to "search the Duck" and look into cron manpages, since I am not familiar with cron jobs, I never use them. It would be fine to be able to establish a trim cron job on a certain day of the week, and this to work no matter how many times I shutdown and/or restart the system.
All this is needed for knowing, in case I accidentally delete something, if I can still recover it, by knowing that the Trim wasn't yet performed on the SSD.
Re: Trim
Thank you so much for this answer. This is gold. It is the exact info I was looking for, clear concise and to the point. I see, that the One who really Knows, doesn't waste words.dolphin_oracle wrote: ↑Wed Apr 09, 2025 9:38 am anancron runs cron jobs in the hourly, weekly, daily, and monthly schedules based on time stamps from the last run, stored in /var/spool/anacron. if a time stamp doesn't exist, or if a date/time is passed (say, while a PC is off), the jobs will be run within so many minutes of service startup/boot, 5 for daily, 10 for weekly, if I remember correctly.
running missed jobs is an advantage of anacron.
I just checked my /var/spool/anacron/cron.weekly and gives me 20250409. And now I checked again $ cat /var/log/trim.log and MIRACLE, the trim.log file is here, showing me that it trimmed my usb enclosure ssd at 15:22:47. I LOGIN at 12:24 and searched and didn't found the trim.log file just before 12:59:44 (I was lucky I did a w command and kept opened the Terminal, so I was able to recover the time), that means after 35 min since I logged in. What can I take from here? That this is the day of the week at this hour, around 15:00 that my system runs the trim job? I mean, can I expect to see next trim, on next Wednesday at around 15:00 o'clock, even I will multiple power on and power of my system, until then? It looks like a fix date, because otherwise the trim.log file should have been there, when I checked 35 min after login, since you said "if the date is passed, the weekly job will be run within 10 min of service startup".
I am so excited, this is new for me and important to know when the trim take place, to know if I accidentally delete something, if I can recover it, if trim didn't run.
Thank you again. You are the King.

Last edited by danux on Wed Apr 09, 2025 12:02 pm, edited 1 time in total.
Re: Trim
@danux You are very mistaken if you believe trim is the only factor that prevents file recovery on an ssd. There are many factors that can determine deleted file recovery, including the drive mfg and how the process things along with the OS's regular file creation.
If having the ability to retain deleted files is a priority for you, I would urge you to look into either a subversion on your important files, or a back up which runs continuously and provides retention.
If having the ability to retain deleted files is a priority for you, I would urge you to look into either a subversion on your important files, or a back up which runs continuously and provides retention.
*QSI = Quick System Info from menu (Copy for Forum)
*MXPI = MX Package Installer
*Please check the solved checkbox on the post that solved it.
*Linux -This is the way!
*MXPI = MX Package Installer
*Please check the solved checkbox on the post that solved it.
*Linux -This is the way!