Lightszentip/PI - reduce size of log dir

Created Sat, 01 Jul 2023 00:00:00 +0000 Modified Sat, 01 Jul 2023 10:12:39 +0000
161 Words

How to reduce the size of log dir on pi

To optimize log size and prolong the SD card’s lifespan on your Raspberry Pi, you have several options. The most effective method, ensuring the SD card’s longevity, is by making the following configurations in the /etc/fstab file:

tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=25M 0 0

This will keep log files in memory, significantly reducing write operations to the SD card and its storage usage.

However, this can cause certain applications to malfunction, as their folders cannot be created initially, and users lack the necessary permissions to do so.

To address this issue, you can resolve it by opening the file “/usr/lib/tmpfiles.d/var.conf” and adding the specific folders, for instance:

d /var/log/nginx 755 - - -

By following these steps, you can effectively optimize log size on your Raspberry Pi while maintaining application functionality.

Another solution is to change “q /var 0755” to 0777 to give all user the permission to create a log dir