< 401 ~Speeding up the Raspberry Pi's boot

Low hanging fruit

There's a lot of initial basics. Don't start up all of X. Disable the wifi/bluetooth services on boot or the devices entirely through /boot/config.txt if you can get away with it. Set boot_delay=0 in /boot/config.txt. Add quiet to the kernel cmdline.

Slightly more obscure fruit

Systemd can be a bit obnoxious at times, it's got a lot of services that honestly aren't necessary for every use case but can't be disabled. Like that utmp thing. I don't need that crap logged, but it's seemingly impossible to convince systemd to keep that down.

Anyway, systemd can be a valuable tool at the same time. Specifically the systemd-analyze utility, it's incredibly helpful. If you've got a specific milestone you want to reach as fast as possible, you can feed it a specific service and it'll tell you what kept it waiting. Which brings me to the reason I'm tapping all this out.

Knowing enough to be dangerous

If you look into each service, you can sometimes notice some oddities. Like for example, on my Raspbian install getty.service was blocking for 700ms on rc.local, which was waiting on networking to come online, which was waiting on wpa_supplicant to wake up. Since rc.local was just a shell script that spits out the system's IP address, I disabled that and all's well again. Also have fun playing with disabling random systemd services and applying DefaultDependencies=no to services you care about in a wild attempt at faster boot time.

Upside to all this transparency, you can diagnose all manner of issues where a more closed system would just have you shrugging and dealing with it. Downside, odds are you're like me and don't actually know that much and frequently end up with a system in multiple pieces. So take backups. And figure out how to use systemctl edit to edit an inappropriate dependency/ordering out of a systemd service. And if you figure that one out, shoot me a mail.

Conclusion

Personally I managed to get my Pi booting to a TTY in 3.3 seconds. A full second before my display can initialize itself. And like 10 seconds before bluetooth comes online and is able to connect to my keyboard. But if you're just looking to get your code running and don't need much in the way of I/O, you can get pretty fast with it.