Diagnosing chronically slow startup on RPi4 + SSD

Hi all,

Long-time HA / HAOS user here running on an RPi4 + SSD and am generally happy with the performance, even allowing for the relatively modest performance of the device. But at some point over the last 6 months, my boot performance has fallen off a cliff and reboots gone from taking 30 seconds, to taking 10 minutes+. I’ve added a few integrations, for sure, and the RPi is doing a bit of work in the background, but I’d like to understand if the problem is one of configuration, a ropey integration or just having outgrown the RPi.

I could just start disabling integrations until I find the rogue one, but is there a more scientific way to diagnose slow boots?

A snip from the most recent boot log:

2023-03-01 22:05:28.425 WARNING (MainThread) [homeassistant.setup] Setup of input_text is taking over 10 seconds.
2023-03-01 22:05:28.428 WARNING (MainThread) [homeassistant.setup] Setup of input_datetime is taking over 10 seconds.
2023-03-01 22:05:28.430 WARNING (MainThread) [homeassistant.setup] Setup of input_button is taking over 10 seconds.
2023-03-01 22:05:28.432 WARNING (MainThread) [homeassistant.setup] Setup of counter is taking over 10 seconds.
2023-03-01 22:05:28.433 WARNING (MainThread) [homeassistant.setup] Setup of input_select is taking over 10 seconds.
2023-03-01 22:05:28.434 WARNING (MainThread) [homeassistant.setup] Setup of input_boolean is taking over 10 seconds.
2023-03-01 22:05:28.435 WARNING (MainThread) [homeassistant.components.scene] Setup of scene platform homeassistant is taking over 10 seconds.
2023-03-01 22:05:28.436 WARNING (MainThread) [homeassistant.setup] Setup of input_number is taking over 10 seconds.
2023-03-01 22:05:28.438 WARNING (MainThread) [homeassistant.setup] Setup of timer is taking over 10 seconds.
2023-03-01 22:05:28.440 WARNING (MainThread) [homeassistant.setup] Setup of schedule is taking over 10 seconds.
2023-03-01 22:05:28.442 WARNING (MainThread) [homeassistant.setup] Setup of group is taking over 10 seconds.
2023-03-01 22:05:28.443 WARNING (MainThread) [homeassistant.setup] Setup of application_credentials is taking over 10 seconds.
2023-03-01 22:05:28.444 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform uptime is taking over 10 seconds.
2023-03-01 22:05:28.446 WARNING (MainThread) [homeassistant.setup] Setup of proximity is taking over 10 seconds.
2023-03-01 22:05:28.593 WARNING (MainThread) [homeassistant.components.sensor] Updating command_line sensor took longer than the scheduled update interval 0:00:10
2023-03-01 22:05:28.624 WARNING (MainThread) [homeassistant.components.switch] Setup of switch platform template is taking over 10 seconds.
2023-03-01 22:05:28.631 WARNING (MainThread) [homeassistant.components.threshold.binary_sensor] State is not numerical
2023-03-01 22:05:29.036 WARNING (MainThread) [homeassistant.components.light] Setup of light platform switch is taking over 10 seconds.

If I had to point at an obvious cause, it’s this:

2023-03-01 22:10:14.200 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: raspberry_pi

…which was repeated several times in the logs over the course of several minutes of boot time.

Any thoughts from anyone?

I have this crop up from time to time on my Pi4 with ssd, similar logs as yours.

I do a system shutdown from HA, then remove power from the pi, power back up and all is restored with a speedy reboot again whenever required.

It may occur once every couple of months.

Thanks - I’ve actual traced mine just this morning. It was a custom_component (that I maintain) which had a library dependency pointing at github rather than pypi. As such, it was downloading and building the library from source every reboot, which was taking several minutes every boot. I’ve now fixed and re-released the component and it’s much better now.

I still have a command-line sensor that takes a few minutes to run, which I’d love to have not run on boot time, but it seems that this isn’t possible today.

As a note, when it reports “Raspberry Pi is starting”, it really does seem to mean that it’s initialising HA itself, so it’s a bit of a misnomer. I traced this by SSHing to 22222 and watching “top” to see what was taking CPU cycles during startup / restart of HA.

It sounds like there really was something occurring in your case which needed attention.

For me it may be just a glitch, this morning after I rebooted it was still not ready after 20 mins, various integrations reporting errors, HACS unable to finish loading etc etc. I’d seen this before, so did a full power off, then it was up again in about 30 secs, I had an update to apply, after which it again rebooted in almost no time at all, well quick enough anyway.