What does HackerNews think of log2ram?
ramlog like for systemd (Put log into a ram folder)
99% of the time it's the verbose logging of application servers that is the culprit of sdcard failures.
Our $job dashboards used to nuke an SD card every couple weeks/months, but since the move to logs-in-RAM we've been running the same SDs for years.
DIY via {fs,journalctl} config , or using https://github.com/azlux/log2ram
Also, mount the SD with the `noatime` flag of course: https://wiki.archlinux.org/title/Ext4#Disabling_access_time_...
If this is the problem, the solutions are no swap and log2ram https://github.com/azlux/log2ram
I also noticed that Armbian logs to a ramdisk. I didn't investigate the implementation and if its contents survive a reboot.
The only real problems for me are that the SD card will eventually fail no matter what (I mean, much sooner than a SDD or HDD) and that there are basically no Pis at sale at a reasonable price. As a platform it is nearly dead.
Similar PSA: a common Pi complaint is that SD cards wear out quickly under 24/7 use. Routing most logs to memory rather than disk vastly reduces the wear on the SD: https://github.com/azlux/log2ram
Depending on the use case, RAM disks are also pretty easy to set up for any temporary/volatile storage used by shell scripts and the like.
1. A little how-to for storing your logs in RAM, a la Armbian style:
- https://github.com/azlux/log2ram (It's still updated)
2. Move your SWAP to ZRAM, again Armbian style:
- https://github.com/foundObjects/zram-swap
This two will improve your SD card life considerably.
You can mitigate this somewhat with https://github.com/azlux/log2ram
With some finagling you can get them to boot an OS from an external disk then your SD card can just hold a read-only boot loader.
Explanations: The script creates a /var/log mount point in RAM. So any writing of the log to the /var/log folder will not actually be written to disk (in this case to the sd card for a raspberry card) but directly to RAM. By default, every hour, the CRON will launch a synchronization of the RAM to the folder located on the physical disk. The script will also make this copy of RAM to disk in case of machine shutdown (but cannot do it in case of power failure). This way you avoid excessive writing on the SD card.