Apr 22nd 2013


Hardware Watchdog on Rpi

Before I move the Raspberry Pi to dedicated hosting in the Netherlands. One clever thing to do would be to enable the hardware watchdog present in the Broadcom SoC it uses.

This is a rules based system where a hardware reboot will be forced should one of several conditions be met..or if the Watchdog device doesn't get a tick from the daemon every 10 seconds.

The idea is that if the system has crashed then it will be automatically rebooted...Possibly quite useful given I won't have physical access.

Assuming you are running one of the default Raspbian builds this is actually very simple

Enable the Watchdog kernel module and load it into the running kernel. echo 'bcm2708_wdog' >> /etc/modules sudo modprobe bcm2708_wdog

Install the Watchdog daemon and set it to start on boot apt-get install watchdog chkconfig chkconfig watchdog on

Now edit the configuration file for the daemon using vi (or nano if you can't drive vi). As a minimum you'll need to uncomment the line for the watchdog device. The default is to only reboot if the keep alive pulse isn't received by the watchdog device (system has completely crashed). I've enabled the tests for high load avg and low memory as well. vi /etc/watchdog.conf It's important to not be to aggressive on the test settings...This is a hard reboot without any clean shutdowns or filesystem sync so it's possible that repeated triggering of this will result in filesysystem corruption that cannot be cleaned automatically at the next boot. This would result in your Rpi not being available and potential data loss.

It's also possible that someone will find a way to get the system load up to your trigger points at which point you have a potential DoS attack vector. I've set mine to trigger on 1 page of memory free or if the load avg for 5 mins is over 25.

Finally once you are happy start the Watchdog daemon or reboot the Rpi /etc/init.d/watchdog restart

If you want to test this then go and read up about fork bombs but be aware that if it doesn't work and you have no access to reboot then you will have locked yourself out of the system. Also naturally a successful test will result in a hard shutdown and reboot so be mindful of what you have running at the time (shut down databases etc first)


leave a comment

Sorry I hate these captcha things as much as anyone, but I hate people advertising viagra on my site even more so I need to you to complete the test below: