What is the average lifespan of the µSD card in a PI, and why not another paradigm?

122 views
Skip to first unread message

PC

unread,
Nov 19, 2022, 4:49:26 AM11/19/22
to weewx-development
Hello,

According to your experience, what is the average lifespan of the µSD card in a PI. I think for example of the images which are crushed every 5 minutes, which causes, as you know, premature wear.
Can we imagine a paradigm shift: I am only a self-taught programmer, but personally, depending on the frequency of the file, I include in its name the minimum of the date. I can thus accumulate files up to a certain point, and I purge periodically.
And as soon as I can, I use the ramdisk

What do you think ?

Tom Keffer

unread,
Nov 19, 2022, 7:36:26 AM11/19/22
to PC, weewx-development
I think the lifespan is much longer than you think. In 2014 I started an experiment to see how long a card could last. Now, nearly 8 years later, it is still going strong: https://www.threefools.org/weewx/status/

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/832dff0b-bfc4-40ac-9575-119a750ebe84n%40googlegroups.com.

Greg Troxel

unread,
Nov 19, 2022, 8:30:00 AM11/19/22
to PC, weewx-development
I have only had one failure among several RPIs, I think. (I am running
NetBSD but I don't think that matters here.)

I do have my skins generate to /tmp/public_html as this data has no
lasting value and it avoids writes. I don't have a firm belief that
this is necessary -- it was just easy. My weewx RPI3 has been running
since early 2018. (weewx itself late December 2017, and I swapped in a
RPI3 for the original 2006 Macbook.

I am using a 32G card and the machine does only weewx. So writes are
basically logs (normal unix, plus weewx errors only) and database
updates (sqlite3).
signature.asc

Vince Skahan

unread,
Nov 19, 2022, 2:47:47 PM11/19/22
to weewx-development
I have never had a 'micro' SD card fail on any model pi that uses the 'micro' SD card size.

I had 'many' failures on various old model-B pi purchased in 2012 that took the big SD cards.  Those were pretty good at trashing SD cards if you had even slightly shaky power or power supplies.  Purchasing a very high quality SD card helped somewhat but after a few years they'd eventually fail too.  Fortunately I automated my pi builds with ansible so it was a 10-minute annoyance if it happened :-)

But to answer - public_html is not a concern....

/var/log is where your os is doing the most writing, especially if you run a high debug level in weewx.

Simplest hardening change is to add three lines to fstab to mount  /tmp, /var/log, and /var/tmp as tmpfs mounts (essentially into ramdisk) by adding the following to /etc/fstab.   This gets you close enough to read-only without working too hard.  I have not had a failure on any pi of any model in many years since making the following change:

tmpfs           /tmp            tmpfs   defaults,nosuid,mode=0755,nodev,noatime   0       0
tmpfs           /var/log        tmpfs   defaults,nosuid,mode=0755,nodev,noatime   0       0
tmpfs           /var/tmp        tmpfs   defaults,nosuid,mode=0755,nodev,noatime   0       0


Currently running one model-B, one pi3, and one pi4 here, all with the fstab modifications above.  No UPS. Works great.

Note that if you do that, weewx's logs will go poof when you reboot the box.  This typically is not a problem since it is almost never necessary to save the logs and old logs rotate out anyway.

(that said - I *would* worry about the microSD if I was running something like Home Assistant that writes a 'lot' to disk, but moving things carefully to tmpfs would also work for that setup if you worked at it a little)

Graham Eddy

unread,
Nov 19, 2022, 6:35:55 PM11/19/22
to weewx-development
writing log is just sequential; not sure if sqlite3 hits some critical, core database blocks over & over but weewx essentially writes sequentially into tables. it will be interesting to see on tom’s forever machine which expires first - a critical RPI component or the SD’s pool of spare blocks

(i mount ~weewx/public_html on ramdisk and would ~weewx/archive too if it was practical)
⊣GE⊢

Vince Skahan

unread,
Nov 19, 2022, 9:06:28 PM11/19/22
to weewx-development
On Saturday, November 19, 2022 at 3:35:55 PM UTC-8 Graham Eddy wrote:
 it will be interesting to see on tom’s forever machine which expires first - a critical RPI component or the SD’s pool of spare blocks


I have a couple model-B that have run over 10 years now, albeit with a couple SD changes along the way, so the pi themselves are very solid.
 

PC

unread,
Nov 20, 2022, 6:46:15 AM11/20/22
to weewx-development
Thank you all for your clarifications

Paul R Anderson

unread,
Nov 22, 2022, 1:02:52 PM11/22/22
to PC, weewx-development
Agree with Tom I believe that the problem is perceived to be worse than it actually is.     
There is a WeeWX Wiki article on ways to reduce the number of writes to your card;
Also given the price of SSD drives these days an option is not to use a Micro SD-Memory-Card, rather use a SATA to USB Cable Adapter along with a Sata SSD.
Let's say a good Micro SD-Memory-Card in the 16 - 32 GB range may cost $10 - $15
A  SATA to USB Cable Adapter cost $10 Plus A 120 GB Sata SSD costs $20. Yes, maybe twice the price, but much more storage capacity, longevity, and peace of mind that it's not going to fail for a long time.
   


--

Paul Dunphy

unread,
Nov 28, 2022, 2:46:55 PM11/28/22
to weewx-development
I agree with Tom and Vince . . . I have never had a micro SD card fail in 10-12 years.  And I have beat them hard with Pi's, dashcams, etc.  I also want to thank Vince for the idea of putting the logs into RAM.  The logs are not important enough to save from boot to boot in most cases.  So while the micro SD cards are rugged, it's an extra load removed by not writing the logs to them.

- Paul VE1DX

morr...@gmail.com

unread,
Nov 30, 2022, 2:43:38 PM11/30/22
to weewx-development
On Tuesday, November 22, 2022 at 2:02:52 p.m. UTC-4 pa...@pauland.net wrote:
...
Also given the price of SSD drives these days an option is not to use a Micro SD-Memory-Card, rather use a SATA to USB Cable Adapter along with a Sata SSD.

I'm booting an RPi4 off a 16 SSD held in an aliexpress USB-SSD holder. It seems faster than with the SD card, although I have not measured. As Paul says, should be more reliable. I could probably do a daily backup to a mounted SD card.

The SSD adapter is a bit too wide, and blocks the ethernet port. A short discussion here: https://www.reddit.com/r/AskElectronics/comments/yv9e2v/looking_for_improvements_to_raspberry_pi_4_to/ on how to improve that. This project is currently underway.


morr...@gmail.com

unread,
Nov 30, 2022, 2:53:37 PM11/30/22
to weewx-development
Another "paradigm" worth considering is a used or refurbished microPC. All the bits and pieces to assemble a running raspberry pi 4 could be $100+, if you can even find one to buy. 

Staples is selling a "Dell OptiPlex 7050 Micro Refurbished Desktop Computer - Intel Core i5-6400T - 256 GB SSD - 8 GB RAM - Windows 10 Pro" for CDN$200. It's a foot square and under 4" tall. I'm guessing would consume ten watts while idling?

Or an old laptop.

Reply all
Reply to author
Forward
0 new messages