Pi-Hole installation, step-by-step.

By | February 20, 2019

# 2021-05 Update

I had to reinstall Pi-Hole on a larger SD card and the install process is slightly different & easier now.
See the COMMANDS section at the bottom for helpful commands to clean up space and update the Pi-Hole.

  1. Go to https://www.raspberrypi.org/software/ and download/run the installer.
  2. Run Raspberry Pi Imager. It’ll show you the default OS with Desktop, but I prefer the lite “headless” version.
  3. Click the white OPERATING SYSTEM button, select “Raspberry Pi OS (other)” and then “Raspberry Pi OS (lite)“.
  4. Select your SD card, then click WRITE.

Once this is complete, wait for Windows to complain about the one partition on the SD card (do not format, just cancel that prompt) and on the other partition Windows CAN open, you place the SSH file (just an empty text file with no extension) as per the instructions below and you’re ready to continue with the PuTTY instructions below.

This will become your DNS and will sinkhole any nefarious/ad requests on your network, so cell phones, tablets & computers will all be far less inconvenienced by ads and annoyances.

You’ll need a 2 GB SD (bigger is better, I recommend 8GB or more) card and your trusty leftover Raspberry Pi.Files to download

  1. Download the Raspbian Lite image.  This goes on the 2GB SD card.
  2. Download Etcher. To burn the image onto the SD card.
  3. Download PuTTY. To connect to the Raspberry after the install.

Run Etcher, select the Raspian image file, then flash it to the SD card.   This took me about 10 minutes.Flash complete

At this point, Windows will freak out over the ext4 partition and say “do you want to format this drive?” – NO!  Click cancel.

Once this is done, create a file called “ssh” in the root of the SD card (the partition Windows CAN access).  It’s a simple text file without an extension, and it contains nothing.  This tells the Raspberry to start the Secure SHell daemon automatically.

You’re off to the races.   Stick the SD card in the RPi and plug in Ethernet and power and give it a minute to start up.

Raspberry on routerI simply looked at my network map to find the “raspberry pi” entry and associated IP address.  PuTTYWith that, I can open PuTTY and connect in to it.
The default login and password at this time (2019-03) is;

  • username: pi
  • password: raspberry

Run sudo raspi-config to change the password and hostname, and update the software if you feel like it.

Back at the command prompt, it’s time to install Pi-hole, which is done by typing this
curl -sSL https://install.pi-hole.net | bashPiHole install

You’ll end up selecting a few options like IPV4/6, IP/mask, the upstream DNS provider etc.  You’ll have to decide if you want it to be your DHCP server (I’d recommend it as it’ll tell you which device in your house is making the requests, otherwise all requests come from your router if that’s still the DHCP server), and you want the web server and interface installed and enabled.

Once you’re done with all the settings, you might want to change or remove the web interface password
pihole -a -p, and then reboot the RPI with
sudo reboot.

Now all you have to do is change your router’s DNS to point to the RPI and you’re done!

To look at the stats on the web interface, go to http://pihole/admin or http://192.168.1.10/admin  (or whatever the IP of the RPI is).

#Helpful Commands

If the PiHole is out of space (log fills up, SD card full, etc.)

  • Pihole flush – this flushes the log.
  • sudo rm pihole.log.*.* – this deletes the log files in /var/log.
  • MAXDBDAYS=14 – add this to the /etc/pihole/pihole-FTL.conf file & reboot (0 disables it).
  • df -h – this tells you the space used on the SD card.
  • free -h – this tells you the total/available/used RAM.
  • ls -lha /etc/pihole/*.db – shows you the database file sizes.

To remove a .db file if it’s used up your available SD card space (4GB card etc.);

  • sudo service pihole-FTL stop – stops the FTL service.
  • sudo rm /etc/pihole/pihole-FTL.db – deletes the db file.
  • sudo service pihole-FTL start – starts the FTL service.


To allow Pi-Hole to use more RAM for PHP;

  • cd /etc/php – to change do the PHP directory/
  • ls – to show you what PHP version you’re running.
  • cd /7.3/cgi – go into the CGI folder (I have version 7.3)
  • sudo nano php.ini – this opens the file for editing.
  • ctrl-w – to search for a string
  • Memory_limit – type this in to search for it.
    change 128M to 510M – close to my 512 max.
  • Ctrl-x – to save the file.
  • sudo service lighttpd restart – restart the HTTP service for the changes to take effect or use reboot -h to reboot the entire pihole, or reboot it from the settings menu in the GUI.

To fully update the Pi-Hole;

  • Sudo apt-get update – this retrieves a list of the latest updates available.
  • Sudo apt-get full-upgrade – this installs all the latest updates.
  • Sudo apt-get autoremove – this removes old/no-longer-used packages.
  • Pihole -up – this updates Pi-hole itself.


Leave a Reply

Your email address will not be published.