[systemd-devel] How to debug why a unit is started when?

Paul Menzel pmenzel+systemd-devel at molgen.mpg.de
Sat Mar 17 17:50:48 UTC 2018


Dear Andrei,


On 03/16/2018 05:04 PM, Andrei Borzenkov wrote:
> 16.03.2018 18:49, Paul Menzel пишет:

>> I am trying to get the GDM login screen started earlier on a Dell XPS 13
>> 9370 with Debian Sid/unstable system with systemd 238. Currently, after
>> selecting the Linux kernel in GRUB it’s only displayed after roughly
>> eight to ten seconds while Linux takes around two seconds [1].
>>
>> Using systemd-bootchart I see that GDM is started quite late [1], and I
>> wondering if there is an option to find out why.
>>
>> GDM’s service unit [2] has the “dependencies” below.
>>
>>      After=rc-local.service plymouth-start.service systemd-user-sessions.service
>>
>> Is there a debug option, where systemd says, why a certain unit is
>> started? For example, reached target X and therefore starting Y.
> 
> systemctl --after (--recursive) --list-dependencies gdm.service
> 
> may be the first step. Or use systemd-analyze chart to see full picture
> of what was started when.

I didn’t know about `systemd-analyze plot`. Please find the SVG file 
attached.

Looking at the log messages, I kind of think it’s related to the 
NetworkManager, but I do not see the dependency. Is it 
`rc-local.service`? It seems to depend on the `network.target`.

```
[…]
Mar 16 15:41:45.807555 xps139370 systemd[1]: Started Network Manager.
Mar 16 15:41:45.807967 xps139370 systemd[1]: Reached target Network.
Mar 16 15:41:45.808938 xps139370 dbus-daemon[507]: [system] Activating 
via systemd: service name='org.freedesktop.nm_dispatcher' 
unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.9' 
(uid=0 pid=574 comm="/usr/sbin/NetworkManager --no-daemon ")
Mar 16 15:41:45.810078 xps139370 systemd[1]: Starting OpenBSD Secure 
Shell server...
Mar 16 15:41:45.811675 xps139370 systemd[1]: Starting Permit User 
Sessions...
Mar 16 15:41:45.813326 xps139370 systemd[1]: Started Unattended Upgrades 
Shutdown.
Mar 16 15:41:45.815009 xps139370 systemd[1]: Starting OpenVPN service...
Mar 16 15:41:45.816894 xps139370 systemd[1]: Starting Virtualization 
daemon...
Mar 16 15:41:45.819299 xps139370 systemd[1]: Started OpenVPN service.
Mar 16 15:41:45.822350 xps139370 systemd[1]: Started Permit User Sessions.
Mar 16 15:41:45.824276 xps139370 systemd[1]: Starting GNOME Display 
Manager...
Mar 16 15:41:45.825718 xps139370 systemd[1]: Starting Network Manager 
Script Dispatcher Service...
[…]
```

```
$ more /lib/systemd/system/rc-local.service
#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
```

Please find the log messages and the systemd-bootchart SVG file attached.


Kind regards,

Paul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20180316?systemd-analyze--plot.svg
Type: image/svg+xml
Size: 70850 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20180317/6c9513c0/attachment-0001.svg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20180317?bootchart-201080316-1542.svg.7z
Type: application/x-7z-compressed
Size: 49582 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20180317/6c9513c0/attachment-0002.7z>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20180317?journalctl-b-o-short-precise.txt.7z
Type: application/x-7z-compressed
Size: 33975 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20180317/6c9513c0/attachment-0003.7z>


More information about the systemd-devel mailing list