1

My Raspberry Pi Zero running Raspbian Stretch Lite (2018-10-09) seems to be slow at boot. First off, the state of the OS:

It is basically a freshly installed image on a properly working Class 10 SD card. I made minor configurations according to https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget (changes in cmdline.txt and config.txt to enable headless SSH over USB access).

The issue is that it takes a consistent 93 seconds to boot. systemd-analyze plot shows me that it's multi-user.target that starts no sooner than 93 seconds past boot, or about 90 seconds past loading the kernel. I tried tweaking some modules with systemctl and managed to speed up other services, but ultimately, the problem seems to be some sort of 90 second timeout with multi-user.target and overall boot time remains 93 seconds.

My systemd-analyze plot can be found at http://svgshare.com/i/8kR.svg.

Is there any way to further troubleshoot this issue? Perhaps a command to definitely override this late start, if that is safe to do?

EDIT: Disabling "Wait for Network" in raspi-config did not help with the issue either. Instead, I manually removed network services from /etc/systemd/system/multi-user.target.wants, which helped. Be carreful, though, as I was told such an approach to be dangerous.

EDIT2: See https://raspberrypi.stackexchange.com/a/90105/92618 for what I did and why it did not work. I found a potentially dangerous way to work around the issue by setting the default start timeout in /etc/systemd/system.conf to 30 seconds (in my case). However, if this timeout is chosen too low, the system does not boot properly!

3 Answers 3

2

I finally found the solution to the problem. My Raspberry Pi Zero is a non-wireless version, but Raspbian Stretch lite comes with the drivers and services that would be used for Bluetooth and WiFi chip. For some reason, this causes a timeout somewhere during boot. The issue was resolved by removing the Bluetooth modules:

sudo apt-get purge bluez -y
sudo apt-get autoremove -y

Additionally, due to running the setup headless, I disabled a few other services:

sudo systemctl disable raspi-config.service
sudo systemctl disable triggerhappy.service
sudo systemctl disable keaboard-setup.service

Those steps, starting with a fresh Raspbian Stretch Lite (2018-10-09) image brought my boot time down to 15 seconds.

1

multi-user.target is the root of Everything.

Try

systemd-analyze critical-chain
2
  • systemctl list-dependencies multi-user.target provided me with, I believe, the same information, but with the added benefit of seeing which dependencies worked, and which didn't, if I interpret the colored green, red and grey dots correctly.
    – TheNik
    Oct 18, 2018 at 23:01
  • @TheNik Not really - if you like wading through hundreds of entries OK - but even then does not give timing.
    – Milliways
    Oct 18, 2018 at 23:03
0

Do not follow this answer! See the edit below.

After additional research, I found out with systemctl list-dependencies multi-user.target that multi-user.target waits for, among others, on dhcpcd.service and networking.service. /etc/systemd/system/multi-user.target.wants contains symlinks to services on which multi-user.target depends. It is possible to use unlink dhcpcd.service and unlink networking.service in /etc/systemd/system/multi-user.target.wants to remove this dependency. I was able to break this 90-second limit and boot in as little as 35 seconds. With additional tweaking, I believe this can be shortened further.

EDIT: I was mistaken. Whether I managed to remove the dependency this way or not, in addition to using unlink, I had also edited the systemd default timeout to 30 seconds in /etc/systemd/system.conf. It was this edit that shortened the boot time, as reverting the file to its original condition increased my boot time back to 93 seconds. Additionally, as pointed out in the comments, manually editing dependencies in such a manner may result in a failure to boot and the need to re-install the system, which happened to me a few times!

3
  • Fiddling with services is fraught with danger! Use raspi-config and turn off wait for network!
    – Milliways
    Oct 18, 2018 at 23:01
  • What is this unlink? How do you exactly use it and what does it do? Can you please improve your answer with this?
    – Ingo
    Oct 19, 2018 at 9:29
  • Do you really used unlink from the command line to delete filenames and remove symlinks on the systemd configuration files? I won't believe it, so I asked. Ok, you have learned it the hard way :-)
    – Ingo
    Oct 20, 2018 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.