SD card wear

While performing the most recent update there was a hiccup and my file system got hosed. My attempts to repair it met with failure. Since I was going to have to reload anyway I decided to test the SD card. It failed miserably. Every single block failed the comparison. I just popped the SD card back into my laptop and it still has the original contents, so, since the test is supposed to be destructive, either badblocks failed its task completely or the card is toast.

I bought a new card and reinstalled OSMC/KODI. Assuming the badblocks test was accurate and the old card was worn out, I started looking for ways to minimize wear on the new card. I don’t really mind spending $10 a year on a new SD card but I’d rather not go through the hassle. One suggestion I found online was to alter /etc/fstab to mount several of the /var directories as tmpfs. This didn’t work quite as planned, with all kinds of complaints about journal issues on reboot and it ending in safe mode. I took the SD card to another computer and put things back as they were. Everything went fine on the subsequent boot.

Is there some way to minimize non-essential writes to the SD card? The tmpfs trick looked promising but obviously didn’t work as intended. Is there some way to get this to work without aborting the boot?

Sorry if this is an old and worn out topic. I did a forum search and didn’t find anything that appeared to cover this specific topic.

A good SD card will last several years. I’ve been using OSMC ones since the project’s inception and they’re still holding up today although they have experienced some performance regression (keep in mind they’re compiling OSMC packages all the time)

I’m interested in optimising for performance rather than durability as they are cheap and good cards that last long are also cheap (in terms of return of investment)

For performance reasons, we don’t write to the card unless absolutely necessary. This includes having non persistent journals

Sam

I use this log2ram service on most of my Pi projects to help reduce SD card wear:

https://github.com/azlux/log2ram

I did try it on OSMC recently and it seemed to work well.

There are other tricks too but I have yet to try them all: http://raspberrypi.stackexchange.com/questions/169/how-can-i-extend-the-life-of-my-sd-card

Most logs already are already stored in memory (small ringbuffer)

From your StackExchange link:

  • noatime already used
  • disabling journal will make users extremely prone to filesystem corruption
  • swap only used on systems with <=256M

Sam

1 Like