I decided to upgrade my Pi-Hole installation. It was running on a RPI3b, with the boot partition on an SD card, and the file system on an SSD. It also used a PoE (power over ethernet) HAT, and apart from the fan on the HAT getting very squeaky and dusty, it was running rather warm.
Time to upgrade to an RPI4b booting direct from a 256Gb SSD. For heat management I embraced the Pi in a purple armour case. While I was doing this, it seemed like a good time to test my Raspberry Pi docking station.
I have a number of KVM switches, one is an 8-port switch, another is a 2-port. I set my main desk with the 8-port switch (there are 5 computers attached to it), and my development rig with a 4-port switch. I only needed 3 ports on the 4-port switch: one for my development rig, one for my RPI5 and one to be used as the 'docking station'.
The third port already has cables for network, keyboard/mouse, HDMI and power. The power cable can be switched out depending on which model of Raspberry Pi I'm using at that moment, and is the only cable subject to change.
This is all on my development rig (which includes an 8-core x86 machine running Linux/Mint and a Raspberry Pi 5 running Raspberry OS and Cinnamon desktop), so it is very handy to have this all together.
I just want to point out that to perform the upgrade requires 2 instances of Pi-Hole to be running at the same time, on separate machines. This can lead to a dangerous situation where the network itself becomes untenable (at least until one of the instances is switched off), but luckily it is only an issue if the DHCP server on Pi-Hole is enabled - which it isn't by default.
So, I install DietPi on the SSD and plug it into the RPI4 and boot it up. I change the hostname to something memorable - it actually doesn't matter what, so I called it “PiHole3”. I installed apt-utils and dev stuff that has to be done manually:
apt install apt-utils build-essential
Then I ran dietpi-software and installed the following:
Then from dietpi-drive_manager I loaded a network share and copied down my cron scripts (in php) and the repository for alive-ho.
Next I installed Rust - again it is something that has to be done manually - and compiled and tested alive-ho. On success, created the service file and got that enabled and running.
Here comes the fun part. First, on the old Pi-Hole, go to the Teleporter tab on the Settings page and make a backup and store it on the network share.
TURN OFF THE OLD PI-HOLE.
On the new Pi-Hole, load up Dietpi-Config and set the network settings to static ip-address, and identify the upstream dns servers and gateway. The static ip-address must be the same as the old one (actually it doesn't but it saves a headache or two if it's the same).
Load up Dietpi-software again and install Pi-Hole. I opted to use Unbound as a 'local upstream' DNS, so that was installed as well.
Once it is all installed, go to a machine with a browser and load up the Pi-Hole admin page and go to the settings page. On the teleporter tab upload the settings you saved earlier and then on the DHCP tab enable DHCP.
At this point, none of your other computers will be visible by name on the network. You have two options: reboot each one of them or wait until their leases run out, at which point they'll acquire new leases.
The first option makes the machines visible by name as soon as they've rebooted. However, they will almost certainly get new ip addresses (unless you setup the static leases first). The latter method will see the machines request a new lease for the addresses they already have. It's up to you which way you go. I rebooted everything.
It took a bit longer than I thought, but it was actually fairly painless because I took into consideration preparation of the new machine before switching the old one off.