NOT all that interested in the content of the lighttpd logs (/var/log/lighttpd) after a reboot?
This will save your SD card a bit more.
You need to have sufficient free memory for this, I'm running this on a raspberry pi 3B, not sure if older models have sufficient resources!
First, look at the content of
/var/log/lighttpd, this will give you an idea of the size you need for the TMPFS mount.
We will change the number of rotated logs from 12 (default on Raspbian version april 2019) to 1, so you only need to calculate for
If you're also using munin, or any other application that logs in
/var/log/lighttpd, you also need to take the sizes of these log files into account.
Instructions to create the TMPFS for lighttpd (example 16Mb):
WARNING: ensure you don't already have an entry for
sudo service lighttpd stop
# add /var/www/html/slate7/pages/text to /etc/fstab
sudo sed -i '$ a tmpfs /var/log/lighttpd tmpfs nodev,nosuid,gid=www-data,uid=www-data,mode=0750,size=16M 0 0' /etc/fstab
sudo mount /var/log/lighttpd
sudo service lighttpd start
As soon as lighttpd has started, it will start logging, using the TMPFS mount (the TMPFS mount uses your RAM = memory), so no more writes to the SD card. Simply browse to the pihole admin page to see the log file grow.
Now, we will change the number of rotated logs for lighttpd, saved by the automatic log rotation:
Instructions to change the default (on raspian version april 2019) log rotation:
sudo sed -i '/weekly/s/weekly/daily/g' /etc/logrotate.d/lighttpd
sudo sed -i '/12/s/12/1/g' /etc/logrotate.d/lighttpd
Log rotation will now occur daily, instead of weekly, only 3 logs will be available (current, yesterdays - uncompressed, the day before yesterday - compressed)
If your TMPFS fills up (chosen size to small), lighttpd will stop functioning. Increase the size in
/etc/fstab and reboot. All lighttpd logs are gone (memory is cleared), but lighttpd will recreate them and start with empty log files.
Undo this? Remove the line from