OpenWrt Forum Archive

Topic: Flash memory lifetime

The content of this topic has been archived on 6 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I am running a script that write a log every hour, into /overlay to guarantee to be readable even if the router goes down.

The question is, is it a bad idea taking into account the flash lifetime? Should I reduce the frequency? For instance, once a day, or is it ok to keep it once a hour?

The reason OpenWrt does use tmpfs (RAM) for log files is because onboard flash is more valuable than some
external attached log storage.
Logging to a remote server or a USB/GPIO attached (exchangable) storage are solutions too.

However - you can check the Data Sheet of the flash used in your router. These datasheets should be available on Manufacturer or some reseller sites for popular chips.

the popular M25P80 lists in "Table 11: Data Retention and Endurance":
Min. 100,000 Program/Erase cycles per block.
Data Retention of Min. 20 years.

So even if you overwrite the same blocks with log data ALL of these block might (!) turn bad after 11 years if you write every hour (1 year=8760 hours).
(data sheet m25p80)

Your Flash question will expand to
- how much do you trust the manufacturing quality of the whole router (soldering all other chips), environment (near lightning strikes, extreme temperatures) to last ~11 years ?
- if your log is "critical" what is your plan regarding other hardware faults that tend to occur more often (ageing:  soldering, electricity: capacitator quality / voltage quality)

Notice that NAND flash is far more likely to go bad - even from reading - than commonly used NOR flash.

I see, indeed I intended to write to USB or alike, but my router do not have one, I am using msmtp to send the logs when it accumulates certain size, but I can not trust /tmp you know.

Well, if I understood you, there is no problem to write this frequency, even though it is not a good practice, I do not think I will remain the same router for 11 years...

I believe WR841ND uses NOR flash.

Thank you.

(Last edited by shinobi on 26 Feb 2015, 15:53)

You could lessen write-stress to the flash memory by storing your data on /tmp (once per hour), and periodically save the data to flash (once every 2...3...4 hours).

Depending on the kind of data to be stored, a data loss of 2...3...4 hours might be acceptable - or not.

I'm using this method for storing weather data every minute into a rrd on /tmp, and every 30min save the data to flash / USB memory, depending on whats available.

You will see my plans in this topic which I have this code (remember to put iptables -N BWTRAFF on /etc/firewall.user), indeed it runs every 5 seconds and records on /tmp directory, but every hour it assimilates the main measures and records on /etc/traff.

On DD-WRT it was a pain in the neck because I had only 64kb available memory, and nvram commit runs at midnight. With OpenWRT I do not have problems with synchronization, but I was concerned about this flash memory issue would put me in trouble in a near future.

I am considering to change the code to record every hour on /tmp too, and do another routine to copy it to NOR memory every 6 hours for instance. Do you think would it be the better alternative?

You could also upload the log file to somewhere in internet using curl or wput.

The discussion might have continued from here.