How to kill CF cards ?
Start a write, and immediately (less than 1 second or so) do a system reset.
Even if the sector gets written very quickly, the controller inside the CF
card may still be busy with internal housekeeping. If you are unlucky some
internal data structures will end up in a corrupted state. To avoid this,
please ensure some delay (a few seconds) between sync and reboot.|
How many erase / write cycles can NAND flash handle ?
SLC flash (used in the 128 MB cards) can do about 100'000 cycles.
MLC flash (used in the larger cards) can do about 10'000 cycles.
This is counted per erase block, typically 64KB or so.|
How about read cycles ?
Almost unlimited. MLC flash can have "read disturb". The controller should
refresh blocks when ECC errors appear.|
How well does the wear leveling work ?
CF controllers perform wear leveling to spread the erase cycles across multiple
blocks, so frequently written blocks such as directories or file allocation
tables don't wear out prematurely. Wear leveling algorithms are proprietary
and undocumented - "secret sauce".|
Why not use SLC flash for large cards ?
SLC flash is about 3.5x the price per bit for large capacities...|
How to avoid unnecessary write cycles ?
• Mount file systems as noatime (no access time). Updating the
time of last access means a lot of unnecessary write cycles.
• Use a RAM disk for temporary files.
• Keep log files (e.g. dmesg) in the RAM disk if possible.
• Live within your means (of DRAM), don't swap to disk.
• Keep indexes in RAM. A single B-tree index update may result in
multiple disk writes. Trade-off - startup will take a bit longer as you
have to scan all records to build the index.
• Preallocate disk space. Allocating disk space in a piecemeal fashion
requires many more writes than when you grab a few MB at once.
• Consider database structures that use a sequentially written journal
instead of random writes.
• Avoid synchronous disk writes. With normal (asynchronous) writes the
buffer cache can combine multiple writes to the same disk block, e.g. when
appending data to a file.