Raspbery Pi: extend the life of the SD card

Flash memory chip and "lifetime" inscription

As we know, flash memory they have a limited life, as they deteriorate with data writes after a few thousand cycles. In principle, for normal use this should not present a major problem, but if we make intensive use of the SD, it can cause problems (especially if we are using the raspic as a server).

So we can extend the life of our SD card in the Raspberry Pi and all thanks to Linux. The aim is to reduce the number of writes on our SD card to pamper more memory and that errors do not appear so early.

For this, there are some good practices that we must carry out, such as using the SD in read-only mode, as if it were a LiveCD. Another option would be to reduce the number of writes made to SD thanks to RAM.

How can this be done? Well with the tool tmpfs. In order for the kernel to write to RAM whenever possible and avoid unnecessary SD writes, we must modify the / etc / fstab file. For this we will add the line:

tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=100m 0 0

El kernel you will be able to mount / var / log in RAM and use it to write there to avoid these writes that would otherwise go to SD. When the data is not needed, the RAM used will be released. So only the necessary RAM is used and efficiently.

As we can see, in the line we have used "size = 100m" so that 100MB can be used, but you can modify the size to which you want, always taking care not to exhaust all the RAM. We have also used / var / log, but there are other files where the kernel usually does many writes, so we can add other lines like the previous ones but with other files such as: / tmp, / var / tmp, / var / run, / var / spool, ...

I hope you liked the trick and found it useful.

More information - OpenSuSE 13.1: for the Raspberry Pi

Leave a Comment

Your email address will not be published. Required fields are marked with *



  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.