[solved] tipp for always super fast booting : dietpi-boot.service type=forking !!!

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
att2
Posts: 14
Joined: Tue Jan 07, 2020 11:42 am

[solved] tipp for always super fast booting : dietpi-boot.service type=forking !!!

Post by att2 »

Hello,

I constantly experienced slow booting > 50 secs when no network is available.

I solved this issue in many little ways, but the main breakthrough was that I changed the type of dietpi-boot.service.

/etc/systemd/system/dietpi-boot.service now contains :
[Service]
Type=forking
RemainAfterExit=yes
StandardOutput=tty

The "type=forking" is important, so it will not wait forever for the network, or if it will, it will do so in the background.
Previously, there was a "type=oneshot" there.

This improved system performance heavily :

Code: Select all

[email protected]:~# systemd-analyze blame

          4.368s dietpi-boot.service
          1.209s dietpi-preboot.service
           574ms dev-mmcblk0p2.device
           427ms systemd-logind.service
           377ms systemd-udev-trigger.service
           327ms keyboard-setup.service
           278ms dietpi-ramdisk.service
           225ms [email protected]
           220ms var-swap.swap
           212ms networking.service
           132ms dietpi-ramlog.service
           128ms systemd-journald.service
            92ms alsa-restore.service
            90ms ssh.service
            75ms systemd-udevd.service

Before this, the service needed more than 30 seconds without network.

Only caveat : If you plugin your network cable later, you will notice that the vsftpd has not started up. Never mind that.

So, my pro-tip to the developers : Speed up booting and change the type of your systemd service to "forking" !!!

Edit the file as described above. After editing it, do a "systemctl daemon-reload" and reboot.
Last edited by att2 on Sun Jan 19, 2020 8:33 pm, edited 2 times in total.

User avatar
Joulinar
Posts: 448
Joined: Fri Nov 15, 2019 11:49 pm

Re: [solved] tipp for always super fast booting : dietpi-boot.service type=forking !!!

Post by Joulinar »

Hi,

this is as expected because your system is waiting on a valid network connection as well as the time sync to be completed. However you could bypass both checks. Just go to /DietPi/dietpi.txt and set the following 2 lines to 0.

Code: Select all

# Delay boot until network is established: 0=disabled | 1=10 second wait max (default) | 2=infinite wait
CONFIG_BOOT_WAIT_FOR_NETWORK=0

# Network time sync: 0=disabled | 1=boot only | 2=boot + daily | 3=boot + hourly | 4=Daemon + Drift
CONFIG_NTP_MODE=0
Now your system should boot quite fast as it doesn't care about valid network connection or time sync.

For testing purposes, I tried your suggested "workaround" but it doesn't has any impact on startup timing on my Demo VM.

Original Settings

Code: Select all

[email protected]:~# systemd-analyze blame
         31.651s dietpi-boot.service
changed to Type=forking

Code: Select all

[email protected]:~# systemd-analyze blame
         31.453s dietpi-boot.service
For me the main benefit is coming from switching off the NTP time sync

Code: Select all

[email protected]:~# systemd-analyze blame
          2.882s dietpi-boot.service

att2
Posts: 14
Joined: Tue Jan 07, 2020 11:42 am

Re: [solved] tipp for always super fast booting : dietpi-boot.service type=forking !!!

Post by att2 »

...on my Demo VM.
Your demo VM is not a real machine!!!!
Test it on a real machine and you will experience the same speedup !

User avatar
Joulinar
Posts: 448
Joined: Fri Nov 15, 2019 11:49 pm

Re: [solved] tipp for always super fast booting : dietpi-boot.service type=forking !!!

Post by Joulinar »

Nope. It did not change anything on my RPi3B+ as well. Doesn't matter if this is a real physical device or VM.

Code: Select all

[email protected]:~# cat /etc/systemd/system/dietpi-boot.service|grep Type
#Type=oneshot
Type=forking
[email protected]:~# systemd-analyze blame
         32.243s dietpi-boot.service
          1.228s dietpi-preboot.service

att2
Posts: 14
Joined: Tue Jan 07, 2020 11:42 am

Re: [solved] tipp for always super fast booting : dietpi-boot.service type=forking !!!

Post by att2 »

Did you do a "systemctl daemon-reload" ?

User avatar
Joulinar
Posts: 448
Joined: Fri Nov 15, 2019 11:49 pm

Re: [solved] tipp for always super fast booting : dietpi-boot.service type=forking !!!

Post by Joulinar »

Yes I did, but did not change anything.

Post Reply