Reduce Log Writes to SD Card on Raspberry Pi OS
log2ram is a software that saves the system logs into ram and flushes it to the SD card at certain times, thus reducing the amount of writes to the SD card and prolonging it’s life. It was created by Erich Styger, https://mcuoneclipse.com/author/mcuoneclipse/
To install it do the following:
$ cd /home/pi
For the next step you need to have git installed. Get the software from git hub:
$ git clone https://github.com/azlux/log2ram.git
The do the installation following these steps:
$ cd log2ram
$ chmod +x install.sh
$ sudo ./install.sh
Edit the log2ram configuration file to set a suitable size for the RAM directory:
$ sudo nano /etc/log2ram.conf
Set a suitable size for your system. Normal use 40MB, as a server, 128MB. Make sure there is enough ram available:
Nest reboot the Pi:
$ sudo reboot
And after the Pi boots up again, check if the new disk is available:
$ df -h
The logs will now be written to the device in RAM and flushed to the SD card from time to time.