What does HackerNews think of log2ram?

ramlog like for systemd (Put log into a ram folder)

Language: Shell

#5 in Raspberry Pi
Reducing logging, logging to ram and writing to the sdcard once a day helps longevity a lot, especially with quality sd cards.

99% of the time it's the verbose logging of application servers that is the culprit of sdcard failures.

https://github.com/azlux/log2ram

The most noticeable raspberrypi SD card life lengthener for me has been to write logs to RAM (assuming you have a stable setup and don't count on them to survive a reboot!).

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_...

> writing permanent its log files and swap partition

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.

In addition to the other helpful suggestions you’ve received, look into using Log2Ram. It does what it sounds like, puts log writes in ram and then writes them to disk on a slower cadence that doesn’t work your SD card that much.

https://github.com/azlux/log2ram

Thanks for sharing, didn't know that.

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

I've had a similar frustration. For what it's worth, sending most logs to RAM drastically reduces the write-thrashing on the SD card, and greatly prolongs the life of a 24/7 Pi: 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.

log2ram [1] can help you with reducing the writes of logging at least. It saves logging to ram and then writes it once a day.

[1] https://github.com/azlux/log2ram

To put the money where my mouth is:

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 use log2ram [0] to reduce the number of writes to the SD card. That's what I'm doing at the moment and haven't had any problems with my SD card, though it has been in use for less than 6 months so far. I agree though that a SD card is not the best storage option for the OS and would like to move mine over to an nvme drive.

[0] https://github.com/azlux/log2ram

Quick plug for log2ram, which greatly reduces the write cycles on the boot SD, especially for Pi's that run 24/7: https://github.com/azlux/log2ram
I've been using log2ram [1] which helps my sd cards survive longer than otherwise.

[1] https://github.com/azlux/log2ram

Most writes are the logs, I use log2ram [1], it reduces SD writes substantially.

[1] https://github.com/azlux/log2ram

SD cards have a limited number of writes so if you have the OS constantly writing to it then eventually it sets itself read-only.

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.

Check out: https://github.com/azlux/log2ram

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.