Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Since flash memory only has a limited number of writes, what tweaks are necessary for installing a Linux system onto flash media so that the OS can run reliably for a long period of time?

Some examples of flash memory installations include burning a Linux image onto a wireless router's flash memory, or installing a linux distro onto a box that uses an SD card for it's hard drive.

Also, besides wireless router firmware (OpenWRT, DD-WRT, etc) which presumably already implements such tweaks, are there any general-purpose distributions that either make these tweaks or allow you to use them as an option?

share|improve this question
Many routers (including my wrt router) mount the root filesystem read-only. For a read-write filesystem, you should use one of the filesystems specially designed for flash: JFFS, JFFS2, YAFFS, etc. – Gilles Mar 5 '11 at 14:31
Not an answer but a reference outlining some of the current problems with the state of the art: lwn.net/Articles/428584 – mattdm Mar 9 '11 at 17:18
up vote 2 down vote accepted

The /tmp and /var directories are the ones that many system programs write to a lot, and depend on being writeable. Minimizing writes to these directories, or configuring Linux to mount these directories on external storage devices that are replaceable, as opposed to on board flash, would go a long way towards accomplishing your goal.

/home and swap partition should be treated the same way.

rsyslogd, the default syslogd in Debian and many Debian-derived distros, has the capability to not write logs to disk, but ship them over a network connection, and only write them to storage if an internal buffer gets full. Implementing this (which I'm trying to figure out how to do currently in a good way) could eliminate a lot of flash writes.

Also, you want to mount your file systems with the noatime option which prevents Linux from updating the access time on each file you touch. This can also eliminate a lot of writes and speed up performance. I think there's also a kernel parameter that controls the time interval between Linux's automatic sync call. If your system doesn't expect to experience sudden power outages you could set that to a higher value than the default of 5 seconds (I think).

share|improve this answer
/tmp should be on an in-RAM filesystem (tmpfs), as should be the parts in /var that don't need to be persistent. – Gilles Mar 5 '11 at 14:28
Only issue with that is many embedded devices with internal flash also have low amounts of RAM. On my Guruplug with 512MB of RAM, I've opted to put /tmp on a USB flash drive, for example. Flashable routers are even worse with 16MB/32MB of RAM. But if your /tmp space requirements are low, do it! – LawrenceC Mar 5 '11 at 14:31
OpenWRT puts /tmp on a tmpfs file system. Frequently changed parts of var which do not need to persist are symlinked into /tmp. There is no default swap device. The filesystem on flash only gets updated when the configuration is changed or files are modified in /root. I mount an old USB flash drive for swap and /home. I should redirect /root to /home/root. – BillThor Mar 5 '11 at 18:29

It would be more proper to say Flash Memory has only a limited number of erase cycles, these caused eventually by writes. There are many good articles available about this distinction.

When you mention burning a Linux image into router firmware, that is probably NOR flash or an EEProm. NOR is the type of flash with quicker reads, NAND the type with quicker writes.

Under ext3, the journal is the most frequently written file, and those writes will eventually fill a block, forcing the erase of another block. Setting a larger commit= value on mount would gather these journal writes into larger chunks.

Finally, to echo other solutions, mounting with noatime is a standard practice that will reduce impact.

share|improve this answer
For all my installations on NAND based storage, I prefer to to use ext4 with the journal disabled. Obviously this has its own set of dangers, and might be risky for most people. – TechZilla Aug 13 '12 at 13:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.