Slow boot on Ubuntu 16.04

After upgrading the desktop machine from Ubuntu 14.04 to 16.04 (both LTS versions), I noticed that booting the machine took quite long.

Years ago I had used bootchart, but that did not work anymore - after booting, no /var/log/bootchart* files existed.

Searching further I saw that we don't need bootchart anymore; the almighty systemd logs boot time itself. We can analyze it with systemd-analyze.

Running it without parameters told me bootup time:

$ systemd-analyze 
Startup finished in 4.138s (kernel) + 33.845s (userspace) = 37.984s

37 seconds? Who is to blame for that time?

$ systemd-analyze blame
         30.326s NetworkManager-wait-online.service
           770ms winbind.service
           746ms nmbd.service
           706ms lvm2-monitor.service
           684ms samba-ad-dc.service
           .. many more

Why does the system wait for that? Can't it simply continue booting without network connectivity?

$ 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.
 
graphical.target @33.829s
└─multi-user.target @33.811s
  └─smbd.service @33.546s +265ms
    └─nmbd.service @32.771s +746ms
      └─remote-fs.target @32.754s
        └─mnt-media\x2ddisa.mount @32.574s +176ms
          └─network-online.target @32.560s
            └─network.target @2.227s
              └─NetworkManager.service @2.029s +197ms
                └─dbus.service @1.822s
                  └─basic.target @1.810s
                    └─sockets.target @1.810s
                      └─docker.socket @1.795s +3ms
                        └─sysinit.target @1.777s
                          └─apparmor.service @1.373s +403ms
                            └─local-fs.target @1.363s
                              └─run-cgmanager-fs.mount @2.047s
                                └─local-fs-pre.target @934ms
                                  └─lvm2-monitor.service @227ms +706ms
                                    └─lvm2-lvmetad.service @301ms
                                      └─systemd-journald.socket @209ms
                                        └─-.slice @206ms

So systemd waits for NetworkManager to get fully online because it needs to mount some NFS shares. Valid point.

But why takes that so long? 32 seconds sounds like some valid time plus 30s timeout.

In the network manager connection settings I found that the IPv4 address was static, but IPv6 was set to DHCP. I have no IPv6 DHCP at home, so the IPv6 DHCP requests were not answered, and NetworkManager gave up after 30 seconds.

After disabling IPv6 completely, the system boots up in 15 seconds now:

$ systemd-analyze 
Startup finished in 4.119s (kernel) + 11.111s (userspace) = 15.231s
$ systemd-analyze blame
          7.610s NetworkManager-wait-online.service
           749ms winbind.service
           724ms nmbd.service
           715ms lvm2-monitor.service
           667ms samba-ad-dc.service

I'd still like to know why network setup still takes nearly 8 seconds, but a quick look did not reveal anything obvious.

Written by Christian Weiske.

Comments? Please send an e-mail.