SD flash reliability


18 posts
by woodsy-al » Thu Dec 20, 2012 2:34 pm
Hi there. I got a question about the Flash SD card tha tthe Raspberry Pi boots from. With linux writing regularly to log files etc, or reflashing the system, how prone is the SD card to the flash starting to wear out and become less fast?

How long would it work or how often can you reflash it without normal use before it breaks and needs to be replaced ?
Posts: 4
Joined: Wed Dec 19, 2012 11:07 am
by SN » Thu Dec 20, 2012 3:00 pm
Well as an indicator I have a Kingston 4Gb card in my internet facing webserver which is capturing images off a wireless webcam and writing them onto the SD card and then using ImagicMagick to timestamp a second copy for display
This writes two 20kb to 40Kb files EVERY five seconds and has been running for 43 days and 15 hours - so that's one and a half million writes into the root filesystem without issue...
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?
User avatar
Posts: 1002
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
by texy » Thu Dec 20, 2012 3:06 pm
Reading/Writing to the SD card is not a problem. Continually plugging the card in and out however is. Since my first Pi delivery - May or June, I,ve broken 4 SD cards now. First they crack, then bits fall off, and eventually the Pi doesn't reconise that it's pluged in. Not the Pi's fault, more my heavy handedness ;)

Texy
"!.8inch TFT LCD + Switch Shield" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=59&t=40674
50p goes to the Foundation ;-)
Moderator
Posts: 1273
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by SN » Thu Dec 20, 2012 3:09 pm
the answer to that is to use microSD cards in an adaptor in the SD card slot - don't 'think' this presents any issues with the Pi itself
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?
User avatar
Posts: 1002
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
by gordon77 » Thu Dec 20, 2012 3:18 pm
I struggled to find an answer to this when I wrote a programme that wrote to the card every few seconds, but then found out how to write to the ram !

http://www.maclife.com/article/howtos/a ... e_worth_it

This article says 100,000 but then there is wear leveliing on top of that ?

I found another artucle that tested a flash stick that failed after 90million writes but still could be read.

Gordon77
Posts: 297
Joined: Sun Aug 05, 2012 3:12 pm
by woodsy-al » Thu Dec 20, 2012 3:28 pm
What about putting just teh bootloader and /boot partition on the flash and have the root filesystem on an external hard disk, would that be possible ?
Posts: 4
Joined: Wed Dec 19, 2012 11:07 am
by texy » Thu Dec 20, 2012 3:35 pm
SN wrote:the answer to that is to use microSD cards in an adaptor in the SD card slot - don't 'think' this presents any issues with the Pi itself



I do now have a couple of 4gig micro's with adapters, but in the early days the micro's were not recommended, although that may of been the faster variety.
Texy
"!.8inch TFT LCD + Switch Shield" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=59&t=40674
50p goes to the Foundation ;-)
Moderator
Posts: 1273
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by hojnikb » Thu Dec 20, 2012 4:33 pm
gordon77 wrote:I struggled to find an answer to this when I wrote a programme that wrote to the card every few seconds, but then found out how to write to the ram !

http://www.maclife.com/article/howtos/a ... e_worth_it

This article says 100,000 but then there is wear leveliing on top of that ?

I found another artucle that tested a flash stick that failed after 90million writes but still could be read.

Gordon77

well 100k rewrites on todays sd cards is just untrue.. Newer cards are rated from 1k up to about 5k at most, becouse flash gemetry is getting smaller and smaller.You can get more p/e out of them, but that all depends on luck. (most of them dont just die when they hit their rated p/e)

But this is nothing to worry about. Any decent brand name sd card should have somekind of wearlevelling, so it should wear out evenly. Also unless you write to your card like crazy, wearout of card is the last thing to worry about. Even if it does happen, data will still be there, so it can always be cloned to a new card..
+°´°+,¸¸,+°´°~ Everyone should have a taste of UK Raspberry Pie =D ~°´°+,¸¸,+°´°+
Rasberry Pi, SoC @ 1180Mhz, 256MB Ram @ 550Mhz, 16GB SD-Card, Raspbian
User avatar
Posts: 75
Joined: Mon Jun 04, 2012 3:59 pm
Location: @Home
by SN » Thu Dec 20, 2012 4:50 pm
hojnikb wrote:
gordon77 wrote:I struggled to find an answer to this when I wrote a programme that wrote to the card every few seconds, but then found out how to write to the ram !

http://www.maclife.com/article/howtos/a ... e_worth_it

This article says 100,000 but then there is wear leveliing on top of that ?

I found another artucle that tested a flash stick that failed after 90million writes but still could be read.

Gordon77

well 100k rewrites on todays sd cards is just untrue.. Newer cards are rated from 1k up to about 5k at most, becouse flash gemetry is getting smaller and smaller.You can get more p/e out of them, but that all depends on luck. (most of them dont just die when they hit their rated p/e)

But this is nothing to worry about. Any decent brand name sd card should have somekind of wearlevelling, so it should wear out evenly. Also unless you write to your card like crazy, wearout of card is the last thing to worry about. Even if it does happen, data will still be there, so it can always be cloned to a new card..

So how on my 4Gb card, am I still running with 1,5 million writes? and these are overwriting the same pair of files over and over again... :?

EDIT - I just checked the script, its actually over 2.2 million writes as there's a 'wget', a 'convert' and then a 'cp' every 5 seconds for the last 43 days
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?
User avatar
Posts: 1002
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
by toysareforboys » Thu Dec 20, 2012 11:25 pm
I'm running an e-mail server on the Pi, with 30 e-mail domains, webmail, pop3/imap/smtp, ad well as Pancake + PHP for the web server (I have php doing a lot of file WRITES too, not just reads).

I too was worried about the SD card wearing out, so I moved the operating system onto SSD just to be a bit safer. Runs way faster too ;)

Image
LICK FOR HIGH RES


Image
LICK FOR HIGH RES!


If you're worried, move your operating system onto USB HDD, then you'll be set :)

http://tafb.yi.org:8000/

-Jamie M.
Seagate GoFlex Home, 1.2GHz ARM (kirkwood), 128MB RAM, Gigabit Ethernet, SATA2. Sandisk Extreme 120GB SSD running Arch ARM Linux 3.6.11-0. nginx + php-fpm = LIVE STATUS hosted right on the SGFH!! http://tafb.yi.org
User avatar
Posts: 136
Joined: Thu Dec 06, 2012 11:01 pm
by Sleep Mode zZ » Fri Dec 21, 2012 2:04 am
SN wrote:So how on my 4Gb card, am I still running with 1,5 million writes? and these are overwriting the same pair of files over and over again... :?

EDIT - I just checked the script, its actually over 2.2 million writes as there's a 'wget', a 'convert' and then a 'cp' every 5 seconds for the last 43 days

You are writing the same pair of files over and over again but you are not writing them to the same physical location on the card. Wear leveling is saving your card.

It seems that SD cards have dynamic wear leveling that writes evenly to the free segments on the card. No invidual segment is written over and over again if there are other free segments.
Posts: 105
Joined: Sun Aug 19, 2012 5:56 am
Location: Finland
by wayner » Fri Dec 21, 2012 4:15 am
toysareforboys wrote:I too was worried about the SD card wearing out, so I moved the operating system onto SSD just to be a bit safer. Runs way faster too ;)
.
I was wondering about what is the fastest media storage for the RPi is it:

1) SD Card
2) SSD connected via USB
3) USB flash drive
4) Mechanical hard drive connected via USB

I have seen your posts on the SSD and I may give that a try but is the bottlenect the USB interface of the SSD/ hard drive? If it is the latter then does it matter if you are using a SSD or traditional mechanical hard drive?
Posts: 16
Joined: Thu Oct 25, 2012 1:40 am
Location: Toronto, Ontario, Canada
by toysareforboys » Fri Dec 21, 2012 4:43 am
wayner wrote:I was wondering about what is the fastest media storage for the RPi is it:
The order from slowest to fastest would be:

1) SD Card
2) USB flash drive (a good one, i.e. http://www.chaintech.com.tw/a511_newsre ... p?serno=72 )
3) Mechanical hard drive connected via USB (all of them preform about the same)
4) SSD connected via USB (even the cheapest crappiest SSD smokes all the rest).

Obviously the USB interface to the SSD is not ideal, you're getting 30mb/sec write speeds instead of the 500mb/sec it's capable of ;)

Any usb mechanical hard drive will give you great performance on the Pi :)

-Jamie M.
Seagate GoFlex Home, 1.2GHz ARM (kirkwood), 128MB RAM, Gigabit Ethernet, SATA2. Sandisk Extreme 120GB SSD running Arch ARM Linux 3.6.11-0. nginx + php-fpm = LIVE STATUS hosted right on the SGFH!! http://tafb.yi.org
User avatar
Posts: 136
Joined: Thu Dec 06, 2012 11:01 pm
by wayner » Fri Dec 21, 2012 4:47 am
Why would the SSD be faster than the mechanical hard drive - I guess this implies that random writes to a mechanical hard drive are lower than 30 MB/s, correct? So the bottleneck is the random write (or read) speed of the hard drive and not the USB 2.0 port?
Posts: 16
Joined: Thu Oct 25, 2012 1:40 am
Location: Toronto, Ontario, Canada
by toysareforboys » Fri Dec 21, 2012 4:55 am
wayner wrote:Why would the SSD be faster than the mechanical hard drive - I guess this implies that random writes to a mechanical hard drive are lower than 30 MB/s, correct? So the bottleneck is the random write (or read) speed of the hard drive and not the USB 2.0 port?
It all depends on what you're using it for. Sequential read and write speeds will be almost identical between SSD and physical hard discs on usb 2.0. The big difference comes in small block (4k) random read and write times. The mechanical hard drive just can't keep up with SSD.

If you're using your pi as a server (web, email, whatever) then 4k random performance is important. If you're using it to stream 1080p videos, it's not ;)

-Jamie M.
Seagate GoFlex Home, 1.2GHz ARM (kirkwood), 128MB RAM, Gigabit Ethernet, SATA2. Sandisk Extreme 120GB SSD running Arch ARM Linux 3.6.11-0. nginx + php-fpm = LIVE STATUS hosted right on the SGFH!! http://tafb.yi.org
User avatar
Posts: 136
Joined: Thu Dec 06, 2012 11:01 pm
by jackokring » Fri Dec 21, 2012 7:08 am
I would assume (though not tested), that any failure to verify a write places the block in a bad block list, and the SD shrinks in size as bad blocks accumulate. Further processing by adapting the file system could use all the unfailed bits in any bad block, by block triplet majority reads.

It is also important to know the state a bit fails in. Tis could be used to utilize blocks which have minor failures, up to 3 bit loss per failed bit if bits always fail in one bit state i.e. 1.

Failure mainly occurs due to over current in the bit cell charging. Modern SD uses a current regulation charge, as opposed to a fixed voltage inrush current (fail).

Would it be possible to use block compression to extend SD lifespan? Probably. Is it done now? Probably not.
Pi=B256R0USB CL4SD8GB Raspbian Stock. 13D https://dl.dropbox.com/u/1615413/Own%20Work/Dimensions.pdf ... Looking for an interesting project to hold my attention.
User avatar
Posts: 485
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
by hojnikb » Fri Dec 21, 2012 3:22 pm
Sleep Mode zZ wrote:
SN wrote:So how on my 4Gb card, am I still running with 1,5 million writes? and these are overwriting the same pair of files over and over again... :?

EDIT - I just checked the script, its actually over 2.2 million writes as there's a 'wget', a 'convert' and then a 'cp' every 5 seconds for the last 43 days

You are writing the same pair of files over and over again but you are not writing them to the same physical location on the card. Wear leveling is saving your card.

It seems that SD cards have dynamic wear leveling that writes evenly to the free segments on the card. No invidual segment is written over and over again if there are other free segments.

Yeah, you dont actually overwrite your whole card 2m times, as it would surly die (unless you have a really really good card with SLC flash)..
+°´°+,¸¸,+°´°~ Everyone should have a taste of UK Raspberry Pie =D ~°´°+,¸¸,+°´°+
Rasberry Pi, SoC @ 1180Mhz, 256MB Ram @ 550Mhz, 16GB SD-Card, Raspbian
User avatar
Posts: 75
Joined: Mon Jun 04, 2012 3:59 pm
Location: @Home
by wbp » Wed May 01, 2013 5:15 am
I realize this is a fairly old thread, but this topic is of interest to me, as I'm setting up a couple of Pi's to collect weather data and serve it to the web. One of them got really slow due to poor SD card performance. I replaced the older class 4 card with a new class 10, and now it runs so fast it almost flies.

Given "wear leveling", it occurs to me that one should use a larger card than needed - wouldn't this have a significant impact (reduction) on the wear? My little servers had 4 GB cards and were running at better than 50% free space, but 16 GB Class 10 cards are so cheap now that's what I got. It seems to me that this gives the wear leveling algorithm 4 times the space to use before it has to rewrite any given block, which should be big improvement in reliability, no?

William
Posts: 3
Joined: Sat Mar 30, 2013 12:34 am