Tech article: how to have a very fast boot time with Raspberry Pi

First of all, if you're into music, and not especially interested in programming / Linux, etc., don't read this article.

Is it possible to have your Raspberry Pi app running less than 8 seconds after you plugged the power cord? Or less than 3 seconds after the Linux boot has started?

Yes. Proof:

systemd analyze

How to do that?

It's simple: you need systemd, the new boot management system in Linux, instead of the previous standard sysvinit. It has now become the new standard on recent distributions like Raspbian Jessie, ArchLinux, etc.

Here is how to create a service that will run as soon as possible.
Just create a file /etc/systemd/system/samplerbox.service containing:

[Unit]
Description=Starts SamplerBox
DefaultDependencies=false            # Very important! Without this line, the service 
                                     # would wait until networking.service
                                     # has finished initialization. This could add 10 
                                     # more seconds because of DHCP, IP attribution, etc.

[Service]
Type=simple
ExecStart=/root/SamplerBox/samplerbox.sh
WorkingDirectory=/root/SamplerBox/

[Install]
WantedBy=local-fs.target

and then do:

systemctl enable samplerbox

On next reboot, it will start!

Moreover, systemd has really great built-in tools to tune the boot time:

So, as a summary, if you want fast boot time on your RaspberryPi, first install a Raspbian Jessie distribution, or any other distribution using systemd. Then start the optimization with systemd-analyze!