Page 1 of 1
Trim
Posted: Sat Mar 29, 2025 4:41 am
by Domenico
Good morning,
I know that the Linux kernel supports TRIM as of version 2.6.33.
Is TRIM enabled by default in MX, or do I need to change some settings or install additional software for it to work? If so, how?
Thanks.
Re: Trim
Posted: Sat Mar 29, 2025 5:49 am
by chrispop99
TRIM is run automatically once a week.
The information is in section 3.1.5 of the User Manual.
Chris
Re: Trim
Posted: Sat Mar 29, 2025 4:21 pm
by fehlix
Domenico wrote: Sat Mar 29, 2025 4:41 am
Good morning,
I know that the Linux kernel supports TRIM as of version 2.6.33.
Is TRIM enabled by default in MX, or do I need to change some settings or install additional software for it to work? If so, how?
Thanks.
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
Posted: Sat Mar 29, 2025 6:03 pm
by AK-47
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.
Re: Trim
Posted: Wed Apr 09, 2025 8:02 am
by danux
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.
Re: Trim
Posted: Wed Apr 09, 2025 8:56 am
by DukeComposed
danux wrote: Wed Apr 09, 2025 8:02 am
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
"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.
danux wrote: Wed Apr 09, 2025 8:02 am
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?
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.
Re: Trim
Posted: Wed Apr 09, 2025 9:38 am
by dolphin_oracle
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.
Re: Trim
Posted: Wed Apr 09, 2025 10:00 am
by danux
DukeComposed wrote: Wed Apr 09, 2025 8:56 am
danux wrote: Wed Apr 09, 2025 8:02 am
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
"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.
danux wrote: Wed Apr 09, 2025 8:02 am
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?
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.
Thank you for reply, man.
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
Posted: Wed Apr 09, 2025 10:59 am
by danux
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.
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.
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.

Re: Trim
Posted: Wed Apr 09, 2025 11:09 am
by CharlesV
@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.
Re: Trim
Posted: Wed Apr 09, 2025 1:19 pm
by danux
CharlesV wrote: Wed Apr 09, 2025 11:09 am
@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.
Thank you for your input Charles.
I want to learn more about Forensics. I used in the past Testdisk to recover partitions on formated disk (hdd), or I undeleted a few files with it and I used photorec to recover a bunch of files. But recovery on SSDs is something new I want to learn more about. I have bookmarked some sites on SSD forensics, I read a little, but I still have to make time to read them throughly. I don't know about mfg, but I will check.
I see there are 2 situation:
1. files to recover from a SSD on which is installed the OS
2. files to recover from an external SSD only with data
I'm interested more in the second variant, since I run MX from usb stick and store my data on an enclosure ssd. This way, maybe, many from the problems you mentioned are excluded. I just want to know, and be ready, to recover an accidentally deleted file/files from such an external only data SSD. I mean, I will do it fast, not waiting for the Trim to hit me up. I bought a 2230 32GB SSD only for doing some tests in this regard. (to see how much data I can recover in first day from deletion, how much the second day, etc.). I will try then also to recover files from that SSD having MX installed and running it a few hours after deletion of files. Maybe if you delete something accidentally and immediately make an image of the drive, to recover from, it is possible to undo the error.
It's just a project I want to play with.
Re: Trim
Posted: Wed Apr 09, 2025 1:23 pm
by DukeComposed
danux wrote: Wed Apr 09, 2025 10:00 am
since I am not familiar with cron jobs, I never use them
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.
You're asking cron questions. cron jobs are going to come up. It's important to point out that trim is a hardware health and performance feature of some SSDs, not a recovery option. Whatever you think trim does, I think you should re-educate yourself on that first and foremost. The form, function, and hygiene of file integrity and an effective backup policy is not solely predicated on whether or not you let a disk maintenance cron job run. Focus on fixing the problem -- fear of data loss -- instead of getting distracted by how cron works and hoping that it will save you after an accident.
Re: Trim
Posted: Wed Apr 09, 2025 1:58 pm
by danux
DukeComposed wrote: Wed Apr 09, 2025 1:23 pm
danux wrote: Wed Apr 09, 2025 10:00 am
since I am not familiar with cron jobs, I never use them
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.
You're asking cron questions. cron jobs are going to come up. It's important to point out that trim is a hardware health and performance feature of some SSDs, not a recovery option. Whatever you think trim does, I think you should re-educate yourself on that first and foremost. The form, function, and hygiene of file integrity and an effective backup policy is not solely predicated on whether or not you let a disk maintenance cron job run. Focus on fixing the problem -- fear of data loss -- instead of getting distracted by how cron works and hoping that it will save you after an accident.
Maybe I don't said all my purposes, hence the misunderstanding. In fact, I like Forensics field and want to learn more about it, especially regarding SSDs since, the recovery on these is more difficult and in a short opportunity window, from what I understand. I already have my data on external SSD and HDD. I bought already a 2TB 2.5" HDD to make a copy of that SSD with data, even though I have a partial copy on a 1TB HDD. Even though, it can appear an error from my part and delete something I need and not already saved elsewhere. I know about the health and performance purpose of Trim, thank you anyways. I never said Trim is a recovery option, this is just your take from what I said. Your advice of having backups is though a good one.
Re: Trim
Posted: Wed Apr 09, 2025 2:05 pm
by CharlesV
danux wrote: Wed Apr 09, 2025 1:19 pm
Thank you for your input Charles.
I want to learn more about Forensics. I used in the past Testdisk to recover partitions on formated disk (hdd), or I undeleted a few files with it and I used photorec to recover a bunch of files. But recovery on SSDs is something new I want to learn more about. I have bookmarked some sites on SSD forensics, I read a little, but I still have to make time to read them throughly. I don't know about mfg, but I will check.
I see there are 2 situation:
1. files to recover from a SSD on which is installed the OS
2. files to recover from an external SSD only with data
I'm interested more in the second variant, since I run MX from usb stick and store my data on an enclosure ssd. This way, maybe, many from the problems you mentioned are excluded. I just want to know, and be ready, to recover an accidentally deleted file/files from such an external only data SSD. I mean, I will do it fast, not waiting for the Trim to hit me up. I bought a 2230 32GB SSD only for doing some tests in this regard. (to see how much data I can recover in first day from deletion, how much the second day, etc.). I will try then also to recover files from that SSD having MX installed and running it a few hours after deletion of files. Maybe if you delete something accidentally and immediately make an image of the drive, to recover from, it is possible to undo the error.
It's just a project I want to play with.
Understanding how things work is excellent, and a worthy goal! Having had around 35 years of forensic work on computers, there is quite a bit to understand - but primarily that is how files are used / and work on a particular OS.
I wont go as ar as to say that *every* mfg has their own method, but many do. And this firmware of how they reclaim space, how they move files for longevity, etc all comes into play - and remember that SSD's move data around on them NOT just at the trim stage either. I use Samsung EVO''s in most computers, (and started using WD NVME Black's on the last 3), and both Samsung and WD have a VERY different method, but they both move data around so that their performance SSD's have higher life span.
I have done very little forensic's on pocket drives, but again you have the same 'mentality' on GOOD drives.
Re: Trim
Posted: Wed Apr 09, 2025 9:12 pm
by danux
CharlesV wrote: Wed Apr 09, 2025 2:05 pm
danux wrote: Wed Apr 09, 2025 1:19 pm
Thank you for your input Charles.
I want to learn more about Forensics. I used in the past Testdisk to recover partitions on formated disk (hdd), or I undeleted a few files with it and I used photorec to recover a bunch of files. But recovery on SSDs is something new I want to learn more about. I have bookmarked some sites on SSD forensics, I read a little, but I still have to make time to read them throughly. I don't know about mfg, but I will check.
I see there are 2 situation:
1. files to recover from a SSD on which is installed the OS
2. files to recover from an external SSD only with data
I'm interested more in the second variant, since I run MX from usb stick and store my data on an enclosure ssd. This way, maybe, many from the problems you mentioned are excluded. I just want to know, and be ready, to recover an accidentally deleted file/files from such an external only data SSD. I mean, I will do it fast, not waiting for the Trim to hit me up. I bought a 2230 32GB SSD only for doing some tests in this regard. (to see how much data I can recover in first day from deletion, how much the second day, etc.). I will try then also to recover files from that SSD having MX installed and running it a few hours after deletion of files. Maybe if you delete something accidentally and immediately make an image of the drive, to recover from, it is possible to undo the error.
It's just a project I want to play with.
Understanding how things work is excellent, and a worthy goal! Having had around 35 years of forensic work on computers, there is quite a bit to understand - but primarily that is how files are used / and work on a particular OS.
I wont go as ar as to say that *every* mfg has their own method, but many do. And this firmware of how they reclaim space, how they move files for longevity, etc all comes into play - and remember that SSD's move data around on them NOT just at the trim stage either. I use Samsung EVO''s in most computers, (and started using WD NVME Black's on the last 3), and both Samsung and WD have a VERY different method, but they both move data around so that their performance SSD's have higher life span.
I have done very little forensic's on pocket drives, but again you have the same 'mentality' on GOOD drives.
Thanks for encouragement, man. I saw a few Youtube forensics videos showing how one can see where in memory the bits of a file are. I have to dig more. I would like to mark as SOLVED my question, but it is not my thread and also I don't figure what is that box I have to check. Probably only the one who started the thread can see that box to mark the thread SOLVED.
My questions were solved by dolphin_oracle's post. In just 3 lines he hit the essence of exactly what I wanted to know: when the fstrim-mx kick in by the cron job. (that 5 for daily and 10 for weekly, minutes within which the jobs will be run, if the date is passed, is awesome info). Now, I can't wait next week to see when the fstrim-mx will be run again to see a pattern for my system. I am also grateful for your input, the "bones" you threw me with mfg and the data being moved different by various SSD brands, according to their firmware, being worthy to follow.
I see you are consistent with your SSD brand choice. I have this little new Transcend SATA ssd to work with, and 2 Hynix Gold P31 (1 TB and 2 TB) to replace the laptop one, and one external for storage. Maybe if I will progress in knowledge about how the data is moved around in these SSDs, and what it can be recovered, we can make an mutual advantageous info exchange, since at least myself, I can't afford to buy many different SSD brands just to see how each and every one behaves.
I didn't quite understand what you meant in the last sentence with "GOOD drives", since I didn't prior mention any brand. Maybe you do refer at storing data on external SSD, not on the one the OS resides.
Re: Trim
Posted: Wed Apr 09, 2025 9:19 pm
by CharlesV
@danux As with all ssd's, nvme's and pocket drives... there are good brands, good models and there are dirt cheap "not worth it" brands .. (I shall call them "not worth it" brands :-) )
Some ssd's are rated for a 5 year warranty ... some are rated for 90 days ... it is pretty obvious which are better. (And having Samsung ask zero questions on a drive that has gone bad and just replace it - no questions asked... pretty much speaks for it self.
Re: Trim
Posted: Tue Apr 15, 2025 1:28 pm
by danux
danux wrote: Wed Apr 09, 2025 10:59 am
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.
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.
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.
FOLLOW UP
fstrim-mx was run by anacron today, Tuesday 15-05-2025, at the same hour as last time: 15:00 o'clock. I was expecting it to be run tomorrow, since it run last Wednesday. So, the weekly trim cron job is working on MXLinux even if it runs from USB stick with persistence.
How we can see in first screenshot, fstrim-mx trimmed my /home on USB stick (I thought, trim works only on SSDs) and a Transcend SSD in an external enclosure. It trimmed 0 bytes, because the only ext4 partition on this SSD is empty, newly formatted.
In the second screenshot, we can see that it was trimmed just /home but not the Transcend SSD, that was inserted in the usb port, but the ext4 partition wasn't mounted this time. I would have believed that trim works whether the partition is mounted or not.
The output of the commands: sudo cat /var/spool/anacron/cron.weekly and cat /var/log/trim.log are not saved if you don't do a Save root persistence (I have it configured to Manual) prior to reboot or shutdown.
This is just for someone interested in this "weekly Trim cron job" subject.
PS. Here are the main commands for this subject, so that the Search of this forum to function for these comments:
Code: Select all
$ cat /var/log/trim.log
*** Tue, 15 Apr 2025 15:00:53 +0300 ***
/home: 1 GiB (1104429056 bytes) trimmed on /dev/loop1
$ sudo cat /var/spool/anacron/cron.weekly
[sudo] password for demo:
20250415
$ sudo cat /etc/cron.weekly/fstrim-mx
#!/bin/bash
# this script is applied to SSD drives for sustained long-term performance and wear-leveling
LOG=/var/log/trim.log
echo "*** $(date -R) ***" >> $LOG
fstrim --all --verbose >> $LOG
Re: Trim
Posted: Tue Apr 15, 2025 1:33 pm
by Eadwine Rose
Please don't post screenshots of code output, they cannot be searched. You can post code on the forum like this:
[code]code output here[/code]
Thanks.
Re: Trim
Posted: Tue Apr 15, 2025 1:47 pm
by danux
Eadwine Rose wrote: Tue Apr 15, 2025 1:33 pm
Please don't post screenshots of code output, they cannot be searched. You can post code on the forum like this:
[
code]code output here[/code
]
Thanks.
Sorry, I'm new at this (posting). You meant to not post screenshots but to actually write the commands and their outputs? In this case I will edit the post and add just the comands in cause: cat /var/log/trim.log and sudo cat /var/spool/anacron/cron.weekly. With screenshosts its easier, since I can put other useful commands to understand the context, like w or lsblk. To write it all by hand it's a little to much

(I am lazy). I think if I let the screenshots, it will not hurt anyone.
Re: Trim
Posted: Tue Apr 15, 2025 1:53 pm
by Eadwine Rose
Since you executed the commands already that would mean select all, copy and paste, chuck code tags around. Not that much work.
Re: Trim
Posted: Tue Apr 15, 2025 2:08 pm
by danux
Eadwine Rose wrote: Tue Apr 15, 2025 1:53 pm
Since you executed the commands already that would mean select all, copy and paste, chuck code tags around. Not that much work.

Now I feel dumb.

No. I am not dumb. I closed the Terminal were I wrote the commands so I couldn't to copy/paste them. I saved the screenshots for my refrence, so I was able to post them here. I edited anyway the comment, writing the commands and outputs in question.
Re: Trim
Posted: Tue Apr 15, 2025 2:23 pm
by Eadwine Rose
Thanks, Just need to add the code tags
[
code]code output here[/code
]
Re: Trim
Posted: Tue Apr 15, 2025 2:44 pm
by danux
Eadwine Rose wrote: Tue Apr 15, 2025 2:23 pm
Thanks, Just need to add the code tags
[
code]code output here[/code
]
Thanks. Now I know.
Re: Trim
Posted: Tue Apr 15, 2025 3:09 pm
by Eadwine Rose
Great, and thanks. Makes for easier searching on the forum by someone seeking help later on.