Jump to content

How often should fstrim be run on an SD card to help lengthen its lifespan?


Myron
Go to solution Solved by TRS-80,

Recommended Posts

Is every 6 hours a good interval to fstrim an SD card?  Is it safe for the SD card to be TRIMed often?  I know that SD card trimming is not like TRIM on an SSD, but the operation performed on a SD card that supports CMD38 performs a similar function, to tell the SD card which pages do not contain valid data.

Link to comment
Share on other sites

  • Myron changed the title to How often should fstrim be run on an SD card to help lengthen its lifespan?

Sounds way too frequent to me.  Unless you are maybe constantly writing to it or something.  In which case you should use something more robust like the sort of (industrial, expensive) hardware they recommend for ZFS cache.

 

In normal usage I would think like twice a year (or quarterly, monthly?) maybe, I dunno.  Why do you think you need to do it so often?

 

On 3/27/2022 at 11:01 AM, Myron said:

I know that SD card trimming is not like TRIM on an SSD

 

Yes and a lot of info out there on the Internet about trimming SSD are out of date.  In most cases all that is done automatically now.  As you point out though, I am not sure how this works on flash devices.

Link to comment
Share on other sites

I changed it to 24 hour intervals, out of curiosity and the result was ...

/: 693.2 MiB (726855680 bytes) trimmed on /dev/mmcblk0p1

 

I think this is configured to do this this once per week via systemd, but I'm not sure if this is working hence creating a cron task.

 

Looks like it is.  I will wait for 4 days and look as /var/log/syslog.

 

root@loki:/usr/lib/systemd/system# systemctl status fstrim.timer
● fstrim.timer - Discard unused blocks once a week
     Loaded: loaded (/lib/systemd/system/fstrim.timer; enabled; vendor preset: enabled)
     Active: active (waiting) since Mon 2022-03-21 14:20:12 GMT; 1 weeks 3 days ago
    Trigger: Mon 2022-04-04 00:00:00 BST; 3 days left
   Triggers: ● fstrim.service
       Docs: man:fstrim

 

Thanks for your technical wisdom. 🙂

Link to comment
Share on other sites

  • Solution

Previous estimate I totally pulled from my rear end, because I have no idea.  :D

 

But sounds like maybe a little more often than I was thinking.  Probably whatever system default is doing is likely fine, unless you really know what you are doing and/or have some reason for changing it?

Link to comment
Share on other sites

@TRS-80 Maybe it's a good thing that I got a 32Gb card in the BananaPi Pro. After a week the systemd task did fire and the result was....

Apr  4 00:00:54 loki fstrim[7422]: /: 20.2 GiB (21645828096 bytes) trimmed on /dev/mmcblk0p1

I may have fstrimmed the card a day or so into the week so this time I have to promise myself to leave it alone and check again in 6 days.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines