Markdown source

# How to implement a customized boot process with splash page and no messages in Debian Stretch

This article illustrates how to achieve a customized boot process with a boot image shown. 
A Debian Stretch lite operating system is assumed.

<div class="alert alert-danger">
  <h2><strong>Danger ahead !!</strong></h2><p>Many if not all, of suggestions contained in this article
  could, if misapplied, easily make your system unreachable or ill behaving in many unexpected ways.
  So, before you start to do changes on some system travelling on next ESA deep space probe or sitting 
  on Mt. Everest top, try them at home on a serial console equipped test system.
  Moreover, keep in mind that when everything else fails, you can physically dismount the SD card and edit the offending files off-line. 

## How to hide all the boot messages and prompts

The first step is meant to get rid of all messages and prompts at the boot.

Edit the following files and carefully make the changes in **bold**.

<pre class="prettyprint">
sudo nano /boot/cmdline.txt 

dwc_otg.lpm_enable=0 console=serial1,115200 console=<b>tty3</b> root=PARTUUID=6b391ee6-02 rootfstype=ext4 elevator=deadline rootwait <b>consoleblank=0 loglevel=3 quiet logo.nologo  vt.global_cursor_default=0</b>

<pre class="prettyprint">
sudo nano /boot/config.txt 

<b># custom splash

Next run the following commands that remove the login prompt and Debian native screen saver: 

<pre class="prettyprint">
sudo systemctl disable getty@tty1
sudo systemctl mask plymouth-start.service

Next reboot and check: you should see no messages anymore (black screen).

	sudo systemctl reboot

## Install and run a customized splash screen

Create under /home/pi an images/ directory and copy there the splash screen bitmap:

	mkdir images
	cp splash.png images/

Install the **fim** graphical utility that is able to copy a bitmap into the frame buffer memory area:

	sudo apt-get install fim
Create a dedicated service

    sudo systemctl edit boot-splashscreen-2.service --force

with the following contents:

<pre class="prettyprint">
Description=boot splash screen

# Do not put here any After/Before clauses, just let systemd do its job !



ExecStart=/usr/bin/fim -q -a /home/pi/images/splash.png 

ExecStartPost=/bin/sleep 3


Test the service 

	sudo systemctl start boot-splashscreen-2.service
enable the service

	sudo systemctl enable boot-splashscreen-2.service
 reboot to check everything is as expected:
	sudo systemctl reboot

What is expected is a full black screen at the start, after few seconds the 
splash screen is shown.
If you didn't configre any other grapphical application, it will stay there till
the next reboot/halt.

Using the following command we can verify that the boot 
splash panel has been started just whene we want.

pi@cm3panel:~ $ sudo systemd-analyze critical-chain

The boot splash is shown in <b style='color:red'>red</b> (bold mine),
just after and well before the achievement of sysinit, as per
its service file.

<pre> @13.296s
└─ @13.295s
  └─ssh.service @13.046s +248ms
    └─ @13.039s
      └─dhcpcd.service @4.928s +8.109s
        └─ @4.921s
          └─ @4.921s
            └─triggerhappy.socket @4.921s
              └─<b></b> @4.920s
                └─systemd-timesyncd.service @4.678s +242ms
                  └─systemd-tmpfiles-setup.service @4.649s +23ms
                    └─<b style='color:red'>boot-splashscreen-2.service</b> @1.630s +3.015s
                      └─<b></b> @1.616s
                        └─boot.mount @1.601s +14ms
                          └─systemd-fsck@dev-disk-by\x2dpartuuid-6b391ee6\x2d01.service @1.322s +274ms
                            └─dev-disk-by\x2dpartuuid-6b391ee6\x2d01.device @1.294s

## What is delaying my bootstrap process ?

In case you need a very short boot time (e.g. if you are using the CM3-Panel as an appliance controller), 
the following suggestions could help

* Disable plymouth-* services
* Disable any other service not strictly needed (e.g. lightttpd)
* Put a static IP address instead of using DHCP client daemon (due to protocol mandatory timeout it takes up to 8 seconds to start)
* Disable avahi-daemon (due to protocol mandatory timeout it takes up to 8 seconds to start)

## dhcpcd.service is lasting forever, how can I speedup it?

In the current Raspbian lite images, the dhcpcd.service has a so-called 
drop-in file, i.e. a file that is changing the package prrovided
systemd .service file.
Specifically, the option -w is getting added: it causes the process dhcpcd to wait
till all the interfaces achieve an IP address.

$ sudo systemctl cat dhcpcd.service 

# /lib/systemd/system/dhcpcd.service
Description=dhcpcd on all interfaces

ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -b
ExecStop=/sbin/dhcpcd -x


# /etc/systemd/system/dhcpcd.service.d/wait.conf
ExecStart=/usr/lib/dhcpcd5/dhcpcd -q <b>-w</b>

Removing that option the service is able to start in less than one second instead of 12.
Of course, that could even trigger anomalous behavior, so it is advisable to use this 
configuration only on systems where the network services are not critical to the appliance working.

## Links

* [How to make a splash screen last longer?](
* [Debian plymouth](
* [Guide: A custom splash screen on the Raspberry Pi, for Raspbian Jessie (The XBone, part 1)](
* [Custom boot up screen](
* [Running a splash screen, shutting down screens and an IoT product service with Python on Raspberry Pi](
* [How do I change the splash screen? RPi3Bv1.2 Jessie](
* [Silent boot on Raspbian Stretch in Console](Mode
* [Plymouth](
* [Raspberry Pi early boot splash / logo screen](
* [Fixed splash screen with network information after Raspbian Boot](
* [Guide: A custom splash screen on the Raspberry Pi, for Raspbian Jessie (The XBone, part 1)](
* [I ❤️ systemd: Running a splash screen, shutting down screens and an IoT product service with Python on Raspberry PI](