Prevent SD card corruption

The past showed that the cause of a broken receiver is often a corrupt SD card. This site gives some hints how to prevent the write access which is the main cause for SD card corruption

SD card quality

A flash cell might write 20,000 times. Load levelling in the controller rotates the wear across lots of cells. To work for a long time, the manufacturer provides spare cells. You buy 16 GB but the card contains 18 GB or 20 GB. A cheap manufacturer saves money by providing only 16.0001 GB.
Don't buy the cheapest No-Name SD cards. Industrial class cards should be the best for a OGN receiver.

The noatime Mount Flag (caution: for experts only!)

If the partitions are not mounted with the flag "noatime" then every read access is also a write access, because the time of each read is written to the meta-data!
Change the file "/etc/fstab" and mount the partitions with "noatime"

Disable Swap mechanism

sudo systemctl stop dphys-swapfile
sudo systemctl disable dphys-swapfile
sudo apt-get purge dphys-swapfile

OverlayFS

The OverlayFS makes the SD card read only. You can always enable or disable the read only file system. The only downside is that if you make changes, you have to remember to disable the OverlayFS before, because otherwise all changes will only live until the next reboot. When OverlayFS is enabled, writable memory (visible to the system) drops to just under 500MB for a Raspberry 2 (with 1GB RAM). But that is quite enough for all "normal" log files that occur during operation. When OverlayFS is disabled, the complete SD card is writable as before.

There are many (complicated) ways to install the OverlayFS. Here is a simple way to install the OverlayFS for a Raspberry Pi:

cd /sbin
sudo wget https://github.com/ppisa/rpi-utils/raw/master/init-overlay/sbin/init-overlay
sudo wget https://github.com/ppisa/rpi-utils/raw/master/init-overlay/sbin/overlayctl
sudo chmod +x init-overlay overlayctl
sudo mkdir /overlay 
sudo overlayctl install 
sudo reboot

Now we can query the status of the OverlayFS:

sudo overlayctl status

… or enable OverlayFS:

sudo overlayctl enable
sudo reboot

… or disable OverlayFS

sudo overlayctl disable
sudo reboot

log2ram

A good deal of write activity on Unix/Linux systems is done by the various log files. These contain helpful information when debugging but once everything is up-and-running you can probably live without most of them.

The "log2ram" tool will set up a ramdisk to write the log files to. Whenever the system is *cleanly* shut down, the recorded log files are transferred to a separate location on the SD card.
This way, you can inspect them as usual, but won't add to the wear and tear of your SD card. The downside is that in the case of a hardware crash or reset they will be lost and you may miss valuable information on what caused the crash.

log2ram on Github

cd ~
git clone https://github.com/azlux/log2ram.git
cd log2ram

Then follow the instructions in README.md

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License