When you work on Raspberry Pi with a storage like a Micro SD card, a lot of writings can be created on logs. To limit this effect and increase the life time of your storage, you can use Log2Ram.

As most of the data written as a gateway are the Linux log files, there is a solution to reduce the number of writes to the SD card using Log2Ram. It creates the mount point /var/log in RAM, so any writes to /var/log will be written to the RAM disk. Every hour, a cron job will write the RAM disk to FLASH, or at the time of a shutdown. So this greatly reduces the stress on the SD card.

Installation on Pi

Following these steps to install Log2Ram:

cd /home/pi
git clone https://github.com/azlux/log2ram.git
cd log2ram
chmod +x install.sh
sudo ./install.sh

Configuration

The configuration is very simple, you must only set the log size

sudo nano /etc/log2ram.conf

Set SIZE variable to 128M.

Save the file.

Reboot the Pi to start correctly the new service

sudo reboot

Checking

After the reboot, you can (must) checking your installation.

df -h

you must have a result like:

df_result

You can also check with mount command:

mount

with a result like

log2ram on /var/log type tmpfs (rw,nosuid,nodev,noexec,noatime,size=131072k,mode=755)

Next Post Previous Post