Pi-Hole support for Read Only on Raspberry Pi

Hello

I have managed to get Pi-Hole working with a read only Raspberry Pi, still having log and queries backed up in memory. Raspberry Pi is really sensible with writing and I have lost several cards (need reformat) because of improper shutdown. Since my Rasbperry PiHole server is the main DNS server of my house, I cannot afford it to be too sensible to improper reboot (my ADSL box can be rebooted whenever needed, it never brick).

I have followed this guide to turn the main partitions read only, get the needed tmpfs, then this script to set properly the /var/log/lighttpd. I got bad permission on /var/log/pihole.log, probably because logrotate has been disabled so I fixed it with a hack in /etc/rc.local.

So, if this interest people, and if this has chance to get into the main project, I can make a cleaner Pull Request with the following enhancement:

  • remount in read write just before updating list of changing conf from the admin UI. For the moment, I need to ssh to my pi hole server and type rw command.
  • save log to somewhere sage before reboot (now, all logs are lost on reboot)

Tell me what do you think.

So what about using an ups (Uninterruptible Power Supply) addon card for the raspberry?
There are some diffrent models available on the market.

I am using such a ups in combination with a 2200mAh LiPo-Battery.
And I have configured it to send me an email if main power interrupts and to safetly shut down the system if it runs 10mins on battery.

Alternatively, a power bank would work too, if it is able to charge its battery and power the output at the same time.

Hi. I didn't knew it existed ! Which one do you recommend ?

Power bank between wall power outlet and Pi.
UPS'es are usually way more expensive.

I think this feature request is somewhat exorbitant since it tackles the issue from the wrong end. I agree with what @TheME said that you should rather look for a stable power supply. I run my Pi since almost five years almost non-stop and it still works - even with the very same SD card, although all the logs are written onto the SD card.

On the other hand - I'm living in an area with lots of industry (and hence power plants) and cannot remember having seen any power outage (not even for a few seconds) since maybe 2005.

@TheME recommends one of the very cheap cards that will just transform the voltage of any connected battery (e.g. 12 V) to a stable 5 V voltage that can be used to power the Raspberry stand-alone. You can build them by yourself (using e.g. an 7805) for about 50 cents.

Good old trusty 7800 an 7900 series.
I used them allot in my soldering period.

The other day, my dad was cutting some woods with an electric saw. He cut the cord for an unknown reason, so the whole house has been shut down.

Another day someone else switched the wrong stuff in the central house switcher.

You cannot expect something like power off to never happen even if you never experienced it yourself. The day you will, i guess you'll love your raspberry pi restart seamlessly.

I didn't say that I'm not prepared for it :wink: In fact, my whole computer equipment is buffered by a powerful UPS in the basement. Each device can fail independently (has its own line to the UPS) without affecting the other devices. This is set up for mitigating the danger of the high-voltage and/or lightning spikes on the electricity grid rather than power losses (the batteries are already a bit tired and won't last longer than maybe 30 minutes).

Else than that, my Pi is protected by such a 50 cents circuit I mentioned:

Wall outlet ---lead-acid battery charger--->  12 V 6 Ah battery  ---7805 makes 5V out of that + some filtering circuity---> Pi device
1 Like

Indeed i dont have an UPS yet. I however highly like being sure my rpi never break under any circunstance, hence this Read Only feature request.

I have bought a UPS hat (PICO). I would highly recommend the pihole team to have this product available on their store, it would be so cool to have a safe PiHole + mini UPS (400 mAh is enough to safely poweroff the pi) AND a nice PiHole case !

1 Like

There is a Pi hat available with our partner supplier PiJuice HAT - A Portable Power Platform For Every Raspberry Pi – Pi Supply

1 Like

I dont see if the pihole case is compatible with the hat. My cases lacks a few milimeters, I had to have a modified version 3D printed so the hat could fit happily :slight_smile: