Flash wear

General PhidgetSBC Discussion.
mdjurfeldt
Fresh meat
Posts: 3
Joined: Sun Jun 12, 2011 4:06 pm
Contact:

Flash wear

Postby mdjurfeldt » Wed Feb 22, 2012 7:13 am

I'm considering storing temporary data in files under /var/run on my SBC2 (1072), data which could be updated several times per minute. Is this advisable?

I guess the answer to this question depends where the filesystem lives.

df -T says rootfs which sometimes is RAM, but looking at the size, I guess this is flash memory, or is it a RAM copy of the flash?

Can I repeatedly modify files safely, or will this cause wear of on the flash memory?

Best regards,
Mikael D.

User avatar
Patrick
Lead Developer
Posts: 3117
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Flash wear

Postby Patrick » Wed Feb 22, 2012 10:08 am

Several times per minute should not be a problem - the filesystem will manage all wear-levelling.

Even if you were updating several times per second - changes are not actually written to flash after every save unless you call sync. Changes are written out on a schedule. If your data is important, you may want to call sync after writing to protect the data in case of a sudden power loss.

If you data is temporary, you should write it to /tmp

-Patrick

mdjurfeldt
Fresh meat
Posts: 3
Joined: Sun Jun 12, 2011 4:06 pm
Contact:

Re: Flash wear

Postby mdjurfeldt » Wed Feb 22, 2012 11:22 am

Patrick wrote:Several times per minute should not be a problem - the filesystem will manage all wear-levelling.

Even if you were updating several times per second - changes are not actually written to flash after every save unless you call sync. Changes are written out on a schedule. If your data is important, you may want to call sync after writing to protect the data in case of a sudden power loss.

If you data is temporary, you should write it to /tmp

-Patrick


Thanks for this information. Which actual file system is sitting underneath? Is it jffs2?

Best regards,
Mikael D.

User avatar
Patrick
Lead Developer
Posts: 3117
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Flash wear

Postby Patrick » Wed Feb 22, 2012 2:57 pm

It's ubifs.

-Patrick

User avatar
Patrick
Lead Developer
Posts: 3117
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Flash wear

Postby Patrick » Wed Feb 22, 2012 3:07 pm

The flash is rated for 100,000 program/erase cycles per block. The chip has 4096 blocks. The UBI layer handles wear levelling - so it will spread the program/erase operations across the entire chip even though you are re-writting the same file over and over.

So, if you saved a file and called sync 5 times a minute for a year, that would be:

5 * 60 * 24 * 365 = 2,628,000 program/erase cycles

The entire flash can handle: 100,000 * 4096 = 409,600,000 cycles

So, you have used up about 0.6% of the rated lifetime.

Of course, it's not really this simple, but the general idea is that you don't have to worry too much, unless you are saving AND calling sync many times per second.

-Patrick


Return to “General”

Who is online

Users browsing this forum: No registered users and 0 guests