Installing a Pi Hole while reducing the writing on the SD card?

Hi,

A couple of weeks ago, I opened this issue. Basically, the issue is that after a couple of months of use, the SD Card is dying and I'm unable to update Pi Hole and/or the underlying operating system either. It's the second time it happen in 2 years.

The network behind the Pi Hole has ~35 devices and the Pi Hole had ~6 millions blocked hosts.

I'm opening a new issue to gather feedback and good practices tips on how to install a Pi Hole and make sure it will still continue to work properly in the long run.

With 35 devices on the network, you can imagine that there's a lot of logs. But honestly, I don't need the logs, I just need a clean network :slight_smile: So, I'm trying to gather the options that I have here.

Tomorrow I'm going to buy a new SD Card and reinstall a fresh Raspberry Pi OS instance and then re-install Pi Hole.
What would you advise to avoid hammering on the SD Card when using Pi Hole?

  1. Use a good quality power supply of adequate size. This includes both the power supply and the cable you use to connect the power supply to your Pi. Inadequate power is the leading cause of premature SD card failure. Without adequate power, writes to the SD card may not be completed properly.

  2. Use high quality SD cards with plenty of space. They don't have to be specific high endurance cards. I have had great success over 5+ years with SanDisk Ultra cards, 32 GB. Zero failures on multiple Pi's running 24/7. The reason you want to use larger SD cards is that this provides a larger wear surface for writes.

I have about 40 devices on my network. The logs are driven partly by the number of clients, but more by the number of queries from those clients. If you have a poorly behaved client repeatedly requesting a blocked domain, that will drive more log entries.

My 40-ish clients made 55K queries in the past 24 hours. I suspect this is typical for a network that size.

Note that Pi-hole is not the only software running on your Pi that writes to the SD card. The OS itself makes entries in various logs, etc.

1 Like

Hi !

I've always been using the default power transformer shipped with the Pi bundle and also very good SD Cards quality. The PI only runs Pi Hole and a wireguard server for VPN, I don't even need XWindow and all these stuff.

I usually do the updates once a week, maybe it was too much? Don't know.

Regarding the OS, I was wondering if having /var/log/, /var/tmp and /tmp as tmpfs, that would reduce the SD Card writes operations. WDYT ?

I disabled file swapping on my Pi 2b and noticed a better behavior. The Ram is big enough for working with pi hole.

The 2b works on the router USB port, never had a voltage underrun, not in any system report.

You could disable the long -term database
https://docs.pi-hole.net/ftldns/configfile/#dbfile

And/or disable logging to /var/log/pihole/pihole.log with pihole -l off

I will try that.

How can I do that when PiHole is managed in Docker? Is there an environment variable to set?

I finally managed to install PiHole, Grafana, Prometheus, Loki in NixOS on Raspberry Pi 400!

Everything is managed in a single configuration file and work like a charm.

Looks really nice!

I'm finally ready to have any issue with my SD Card, I can reinstall my complete system in a single command line thanks to Nix!

I'm not using the docker container myself, but it should be

QUERY_LOGGING="false"
FTLCONF_DBFILE=

See: GitHub - pi-hole/docker-pi-hole: Pi-hole in a docker container

1 Like

When I add FTLCONF_DBFILE=, the resulting pihole-FTL.conf is:

#; Pi-hole FTL config file
#; Comments should start with #; to avoid issues with PHP and bash reading this file
PRIVACYLEVEL=0
LOCAL_IPV4=192.168.2.10
REPLY_ADDR4=192.168.2.10
RATE_LIMIT=1000/60
declare=-x FTLCONF_DBFILE=""

And I got this error in the frontend:

To fix this, I had to mount the volume and edit the file manually.

Ah yes, I guess the environment variable handling needs a special case for this valid empty configuration (@DL6ER , could FTL be modified to accept an explicit none/false value here?)

@DL6ER , belay that request.


@PolDellaiera I located the bug in the docker startup script and have fixed it for the next version...:

Give it about 10 minutes or so and it will be built.. (follow along here if you're desperate!) let me know if it works for you or not.

From that version on you should™ be able to set FTLCONF_DBFILE="" and it will be parsed correctly.

1 Like

I left the Raspberry auto update thanks to NixOS workflows and everything is fine now, thanks :slight_smile:

I'm positively surprised of your response time when it comes to bug fixing, I'm glad to be one of your sponsors!

Just for your information,

I've been playing a lot with PiHole and Grafana... and I succeeded to make a cool dashboard with the existing PiHole API.

The thing is that to do that, I had to use specific Grafana functions (delta), to compute the changes between the current data and the previous one.

Are there any plan to improve the current API?

  • Like providing real time informations instead of a history?
  • Like exposing more data?

Thanks!