raspberry pi - SD card write limit - data logging -



raspberry pi - SD card write limit - data logging -

i want track/register when scheme (a raspberry pi) shut down, due abrupt powerfulness loss.

i want recording heartbeat every 10 minutes sd card - every 10 mins it'd go sd , write current time/date in file. harm sd in long run?

if there's 100k write cycles it, it'd have bad block in couple of years. i've read there's circuitry prevent - prevent bad block? safer distribute log in several blocks?

thanks

the general reply question strong "it depends". (practical reply have; if file scheme parameters not wrong, have big margin in case.) depends on following:

sd card type (slc/mlc) sd card controller (wear levelling) sd card size file system luck

if take @ flash chip, organised sectors. sector area can erased (actually reset state 1's), typically 128 kib sd cards. zeros can written bit-by-bit, way write ones erase sector.

the number of sector erases limited. erase operation take longer each time performed on same sector, , there more uncertainty in values written each cell. write limit given card number of erases single sector.

in order avoid reaching limit fast, sd card has controller takes care of wear levelling. basic thought transparently user card changes sectors used. if request same memory position, may mapped different sectors @ different times. basic thought card has list of empty sectors, , whenever 1 needed, takes 1 has been used least.

there other algorithms, well. controller may track sector erase times or errors occurring on sector. unfortunately, card manufacturers not tell much exact algorithms, overview, see:

http://en.wikipedia.org/wiki/wear_leveling

there different types of flash chips available. slc chips store 1 bit per memory cell (it either 0 or 1), mlc cells store 2 or 3 bits. naturally, mlc chips more sensitive ageing. three-bit (eight level) cells may not endure more 1000 writes. so, if need reliability, take slc card despite higher price,

as wear levelling distributes wear across card, bigger cards endure more sector erases little cards, have more sectors. in principle, 4 gib card 100 000 write cycles able carry 400 tb of info during lifetime.

but create things more complicated, file scheme has lot this. when little piece of info written onto disk, lot of different things happen. @ to the lowest degree info appended file, , associated directory info (file size) changed. typical file scheme means @ to the lowest degree 2 4 kib block writes, of 1 may append (no requirement erase). lot of other things may happen: write journal, block becoming full, etc.

there file systems have been tuned used flash devices (jffs2 beingness common). all, far know, optimised raw flash , take care of wear levelling , utilize bit or octet level atomic operations. not aware of file systems optimised sd cards. (maybe academic interests create 1 taking wear levelling systems of cards account. result in nice paper or few.) fortunately, usual file systems can tuned more compatible (faster, leads wear , tear) sd card tweaking file scheme parameters.

now there these 2 layers on top of physical disk, impossible track how many erases have been performed. 1 of layers complicated (file system), other (wear levelling) non-transparent.

so, can create rough estimates. let's guess little write invalidates 2 4 kib blocks in average. way logging every 10 minutes consumes 128 kib erase sector every 160 minutes. if card 8 gib card, has around 64k sectors, card gone through 1 time every 20 years. if card endures 1000 write cycles, 20 000 years...

the calculation above assumes perfect wear levelling , efficient file system. however, safety factor of 1 000 should enough.

of course, can spoiled quite easily. 1 of easiest ways forget mount disk noatime attribute. file scheme update file access times, may result in write every time file accessed (even read). or os swapping virtual memory onto card.

last not to the lowest degree of factors luck. modern sd cards have unfortunate tendency die other causes. number of lemons quite well-known manufacturers not small. if kill card, not because of wear limit. if card worn out, still readable. if dead, has died of else (static electricity, little fracture somewhere).

raspberry-pi hardware sd-card fat

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -