_Mark_
Posts: 101
Joined: Sun Jun 02, 2013 8:04 am

Speed up Raspbian boot

Fri Oct 20, 2017 12:39 pm

I'm customizing a Raspbian Stretch Lite image to fit my needs. I'm quite fine with the results but now I would like to speed up the booting process because it takes so long to complete.

Here some outputs:

Code: Select all

$ systemd-analyze 
Startup finished in 1.653s (kernel) + 1min 31.345s (userspace) = 1min 32.999s

Code: Select all

$ systemd-analyze critical-chain 
The time after the unit is active or started is printed after the "@" character.
The time the unit takes to start is printed after the "+" character.

multi-user.target @1min 31.250s
└─getty.target @11.659s
  └─autologin@tty1.service @11.658s
    └─rc-local.service @8.212s +80ms
      └─network-online.target @8.196s
        └─network.target @8.165s
          └─networking.service @3.291s +4.871s
            └─local-fs.target @3.249s
              └─run-user-1000.mount @16.903s
                └─local-fs-pre.target @1.907s
                  └─keyboard-setup.service @1.062s +843ms
                    └─systemd-journald.socket @1.057s
                      └─-.mount @872ms
                        └─system.slice @1.022s
                          └─-.slice @872ms

Code: Select all

$ systemd-analyze blame
          4.871s networking.service
          4.634s dhcpcd.service
          4.551s busybox-syslogd.service
          4.393s raspi-config.service
          3.304s plymouth-quit-wait.service
          3.289s plymouth-quit.service
          1.999s dev-mmcblk0p2.device
          1.883s nmbd.service
          1.336s lighttpd.service
           972ms smbd.service
           843ms keyboard-setup.service
           738ms systemd-logind.service
           685ms ssh.service
           ...
As far as I understand the networking applications take over 14 seconds (networking.service, dhcpcd.service, nmbd.service, smbd.service, lighttpd.service, ssh.service).

Questions:
  1. about the networking applications, do you think the delays are acceptable or there is a way to improve them?
  2. what does the raspi-config service do? It says "switch to ondemand cpu governor". Might I safely disable it?
  3. why the playmouth service take over 6 seconds to quit? Is it normal?
Please, don't propose alternatives like keeping the Raspberry always powered... I just want to reduce the boot time!
Thanks in advance!

User avatar
SlowBro
Posts: 169
Joined: Sat Feb 18, 2017 1:30 am

Re: Speed up Raspbian boot

Sat Oct 21, 2017 3:57 am

I don’t have a lot of direct answers to your questions but I’ve looked into boot optimization as well. One thing I noticed is your boot time seems much longer than mine, and I’m on stretch lite as well. Do you need Samba? Out of the box on my B+ it’s about 30 seconds to boot. I do have a very fast sd card though.

Other ways to go faster: Try TinyCore or Arch. Boot times less than 10 seconds are reported.

I gave up the pursuit of faster boot and just decided to stay online all the time, or at least shut down less frequently. I know you don’t want to hear that, but these things aren’t microcontrollers which can come online in milliseconds.

If you can do that though it could work. I was developing on MicroPython on the ESP32 but found it too constrained and quirky. Switched to the Pi and am quite pleased.

Lastly, think about a different chip. Take for example the SAMA5 family. Runs Linux and can go into deep sleep sipping battery. Boots back in milliseconds. You would need to develop your own board though. I’ve never done that but that looks like something I could learn to do in a few months? The memory traces concern me as maybe being too difficult for a novice like me. IDK.

What are your goals?

_Mark_
Posts: 101
Joined: Sun Jun 02, 2013 8:04 am

Re: Speed up Raspbian boot

Sat Oct 21, 2017 6:00 am

Hi, unfortunately I need all those services. Those I don't need I've already disabled.
I know TinyCore or Buildroot. But the major drawback is they are bound to a specific processor. Instead my Raspbian image works fine with all RPi models (tested on B+, 2 and 3).

Of course I can change hardware but it took 3 months of development to customize the o.s. (filesystem ro, qt5, and a lot of other stuff) so I'm just trying to optimize something.

I want to understand if there is anything I could change to improve boot times.
I.e. I need samba, but it's fine if it is started after my application. It's a machine controller that is turned on and off on demand, hence a reduced boot time will be appreciated by the users.

User avatar
SlowBro
Posts: 169
Joined: Sat Feb 18, 2017 1:30 am

Re: Speed up Raspbian boot

Sat Oct 21, 2017 11:08 am

That doesn’t sound right. There’s only one image for Tiny Core and it’s said to work with all processors. http://www.tinycorelinux.net/9.x/armv6/releases/RPi/

As I was saying I don’t have a direct answer to your question but another possibility: Make your users realize the system is doing something, if you do not have that setup already. A spinner or in my case an LED to indicate acknowledgement to the user request.

Have you recompiled the kernel? Sometimes that helps. Is your sd card fast enough? Apologies that I don’t have a direct answer, just shooting from the hip here.

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Speed up Raspbian boot

Sat Oct 21, 2017 11:10 am

This is the easiest way to improve boot time.
SlowBro wrote:
Sat Oct 21, 2017 3:57 am
I do have a very fast sd card though.
I use SanDisk Ultra Plus uSD cards. Boots in a hurry.

User avatar
SlowBro
Posts: 169
Joined: Sat Feb 18, 2017 1:30 am

Re: Speed up Raspbian boot

Sat Oct 21, 2017 11:14 am

SurferTim wrote:
Sat Oct 21, 2017 11:10 am
This is the easiest way to improve boot time.
SlowBro wrote:
Sat Oct 21, 2017 3:57 am
I do have a very fast sd card though.
I use SanDisk Ultra Plus uSD cards. Boots in a hurry.
Samsung Evo+ boots in about 30 secs on a stock build of stretch lite. What about yours?

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Speed up Raspbian boot

Sat Oct 21, 2017 11:17 am

I boot into Stretch/Pixel desktop in 17 seconds. Edit: with a RPi3.

I checked with a PNY Prime uSD, and it boots in 18 seconds.

User avatar
SlowBro
Posts: 169
Joined: Sat Feb 18, 2017 1:30 am

Re: Speed up Raspbian boot

Sat Oct 21, 2017 11:49 am

SurferTim wrote:
Sat Oct 21, 2017 11:17 am
I boot into Stretch/Pixel desktop in 17 seconds. Edit: with a RPi3.

I checked with a PNY Prime uSD, and it boots in 18 seconds.
Ok I'm on a B+ so there's that. OP said he is using everything.

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Speed up Raspbian boot

Sat Oct 21, 2017 11:52 am

Big difference. Then an upgrade to a RPi3 with the SanDisk cards is the ticket.

User avatar
SlowBro
Posts: 169
Joined: Sat Feb 18, 2017 1:30 am

Re: Speed up Raspbian boot

Sat Oct 21, 2017 12:06 pm

If it’s a machine controller does it ever need to shut down? I had a goal of battery power but decided to let that go. Mine is on 24x7, although I plan to include solar and battery as an option, so I may revisit boot optimization. Likely I will switch to Tiny/Arch/Buildroot/Yocto if I do that.

tpylkko
Posts: 409
Joined: Tue Oct 14, 2014 5:21 pm

Re: Speed up Raspbian boot

Sat Oct 21, 2017 5:50 pm

not using dhcpd often times improves boot times, but then again dhcp is really handy.

some people claim that using dash shell also is faster to load.

using window manager and no desktop env might help.

recompile minimal kernel

do baremetal (no operating system)

Return to “Advanced users”