Flash wear leveling
- Wear leveling consists in distributing erases over the whole flash device to avoid quickly reaching the maximum number of erase cycles on blocks that are written really often
- Can be done in:
- the filesystem layer (JFFS2, YAFFS2, ...)
- an intermediate layer dedicated to wear leveling (UBI)
- The wear leveling implementation is what makes your flash lifetime good or not
Flash users should also take the limited lifetime of flash devices into account by taking additional precautions
- Do not use your flash storage as swap area (rare in embedded systems anyway)
- Mount your filesystems as read-only, or use read-only filesystems (SquashFS), whenever possible.
- Keep volatile files in RAM (tmpfs)
- Don't use the sync mount option (commits writes immediately). Use the fsync() system call for per-file synchronization.