i want to reduce boot time on my Raspberry Pi 3B+. I'm using this tutorial http://himeshp.blogspot.com/2018/08/fast-boot-with-raspberry-pi.html and i done 1,2 and 3 step. After this i reboot Pi and check systemd-analyze and boot.log file. There are different boot times, boot time in boot.log is probably the real one. Why systemd-analyze shows 3.8s boot time and it isn't correct value? Thanks for help.
1 Answer
Why systemd-analyze shows 3.8s boot time
Actually what it says is "Startup finished in...". At what point "booting" is finished depends on your definition of booting, which is really about context. It could be defined as the amount of time it takes the kernel to load from power on and launch a userland -- I think this would be equivalent to the first number in the systemd-analyze
output (~1.13s), but that is just a presumption.
By "launching a userland" I mean starting the first process (conventionally "init"), which is systemd
. All subsequent process running on the system can be traced back to that one, which is the only one started by the kernel.
The init process involves a bunch of forking, generally persistent processes. Most of these will have a point at which they can be considered set up and running; usually this happens very quickly but it may involve ambiguities -- e.g., the ssh daemon takes some small amount of time to open a port, and is then dependant on networking running before it might be considered functional.
There are mechanisms in the init system for services of to establish when they are ready for dependent processes to start, but this is not required and I think it is actually an unusual relationship -- it doesn't really matter to sshd
whether networking is available or not, it just does to our definition of having it functional.
Point being, the only meaningful definition of when booting is finished is one based on a particular requirement. Notice that lightdm
and the graphical-target
are established in that timeline before networking. This means it was possible to login at that point locally, which is a valid and useful definition of when booting is "finished", but that does not mean every single system service has completed initialization.
There may be system services that are misconfigured and not really being used that never reach a functional state, so a definition which requires "everything be ready" is both hard to establish (because services are not required to report to anything that they are ready) and pragmatically pointless.
boot time in
boot.log
is probably the real one
This is just another definition, and an arbitrary one. It doesn't say anywhere there that "booting is finished". It logs a bunch of specific times for specific checkpoints.
I'm not sure at exactly what point systemd decides to write this file (/var/log/boot.log
), and I actually don't have one on Raspbian -- the systems it does exist on, it is pretty clearly when the pre-login console output ends because it is simply a copy of that. But what you have posted isn't that, I suspect it is actually dmesg, syslog, or journald output.
-
System bootup process help me much to get an overview about booting.– IngoCommented Oct 3, 2019 at 10:21
boot.log
file? Have looked on a default Raspbian installation but without success.