Raspberry Pi 5: the "reboots" that never happened

The journal showed the server rebooting, and the culprit turned out to be a clock without a battery. Plus one real outage and noise from Docker.

A small server on a Raspberry Pi 5 that sits at my country house started behaving strangely not long ago: judging by the journal, it was rebooting, and it was unclear when. The power supply was the first suspect, and it turned out to have nothing to do with it.

Checking the power

Before changing anything, I looked at what the system knows about itself:

uptime                                    # more than a day
cat /sys/class/net/end0/carrier_changes   # 1
vcgencmd get_throttled                    # throttled=0x0
  • uptime is more than a day - the server did not reboot;
  • carrier_changes=1 - the link came up once at boot and never went down;
  • throttled=0x0 - not a single voltage drop since boot. The line shows 5.03 V, the temperature is 54 °C;
  • there are no receive or transmit errors on the interface, and no OOM or kernel panic in the journal either.

Power, the cable and overheating were ruled out right away. The question that remained was where the reboots in the journal came from.

Where the reboots in the journal come from

The Raspberry Pi 5 has an RTC, but the battery is not included, and my J5 connector was empty. In dmesg at startup it looks like this: rpi-rtc sets the system time to 1970-01-01, then systemd notices that the time is earlier than the build date and moves the clock forward.

Next, fake-hwclock sets the last saved time, and chrony gets the exact time from the network and applies it in one step (makestep 1 3). The step can be several days. The time in the journal goes out of order, and journalctl --list-boots draws several "boots" instead of one.

You can tell such phantoms apart by one sign: two boot-ids with the same timestamp, where the start of the second equals the end of the first plus one second.

I watched this live: at the start of the investigation the server showed July 8, and a few minutes later it was already the 12th-13th, and uptime had not reset.

A battery for the RTC

First I tried to get by in software and enabled systemd-time-wait-sync.service, so that the other services would wait for time synchronization. It did not work: the service waits for a mark from systemd-timesyncd, and on this server chrony keeps the time. It hung in activating forever, and I had to disable it.

The official battery for the RTC is the Panasonic ML2020. After installing it, dmesg shows the correct time at startup, and there are no more phantom boots in the journal.

The ML2020 is rechargeable, and charging has to be enabled separately in /boot/firmware/config.txt:

dtparam=rtc_bbat_vchg=3000000

Without this line the battery will run down in a few months, and everything will come back. Charging may be enabled only for rechargeable cells (ML2020, LIR2032). It must not be done with an ordinary CR2032.

The real outage

One real connectivity outage did turn up after all. Over a day, the watchdog on the server recorded four no response from ping lines: one episode of about a minute. Another one, about five minutes long, I caught myself.

The server's own journal is empty at those moments: end0 did not go down, the lease was not lost, the settings did not change. The router was answering me, but it had no ARP entry for the server.

The most likely cause is the router itself: one of its scripts spends about 45 seconds iterating linearly over a large address list. It is the router that needs fixing, the server is the victim here.

Noise in the journal

One of the containers got in the way of the investigation a lot. It crashed six times a day, and the Docker network plugin recreated a virtual interface for it 93 times.

In networkd this looks like a solid stream of Lost carrier and Gained carrier, and next to a complaint about connectivity drops it reads as confirmation of it. These messages have nothing to do with the server's uplink: all of them are about the container's virtual interfaces.

The causes, summed up

  • phantom boots - an RTC without a battery;
  • a rare real outage - an overloaded router;
  • noise in the journal - a crashing container.

None of them has anything to do with the power, which is where I started.

Now, when I hear the complaint "it keeps rebooting", the first thing I look at is the three values from the first check, and only then do I touch the hardware. It takes less than a minute :)

Tags: Diagnostics, Linux, Raspberry Pi, Self-hosting

LinkedIn X Telegram

Read next

Comments