4

I prefer network to setup itself when I start computer, but I prefer to boot earlier and have network connect while I type my password and so on.

Sadly, according to systemd-analyze critical-chain I am waiting for NetworkManager.service startup during boot.

Is there a way to change that so that it still does its network things and it is not delaying boot?

graphical.target @8.083s
└─multi-user.target @8.083s
  └─postfix.service @8.075s +7ms
    └─postfix@-.service @3.904s +4.169s
      └─network-online.target @3.880s
        └─network.target @3.880s
          └─NetworkManager.service @3.495s +384ms
            └─dbus.service @3.492s
              └─basic.target @3.472s
                └─sockets.target @3.472s
                  └─docker.socket @3.469s +2ms
                    └─sysinit.target @3.464s
                      └─snapd.apparmor.service @3.131s +332ms
                        └─apparmor.service @2.990s +136ms
                          └─local-fs.target @2.989s
                            └─run-snapd-ns-cups.mnt.mount @5.417s
                              └─run-snapd-ns.mount @4.544s
                                └─local-fs-pre.target @528ms
                                  └─keyboard-setup.service @376ms +152ms
                                    └─systemd-journald.socket @361ms
                                      └─system.slice @354ms
                                        └─-.slice @354ms

1 Answers1

2

There are two approaches:

1. Edit override config (/etc/systemd/system/network-online.target.d/override.conf)

Type command sudo systemctl edit network-online.target

paste the following config lines

[Unit]
After=graphical.target

That will create an override config at /etc/systemd/system/network-online.target.d/override.conf, which will partially override /etc/systemd/system/network-online.target.

2. Edit unit directly (/etc/systemd/system/network-online.target)

Type command sudo systemctl edit network-online.target --full

Find After= in [Unit] section and change the value to graphical.target

If you accidentally break the configuration, you can find the original one at /lib/systemd/system/network-online.target.


  • sudo systemctl edit --force --full <your-service.service> to create a new service

  • man systemd.unit to read the manual

  • multi-user.target and graphics services are before graphical.target (ref)

man systemd.special to read special systemd units manual

network-online.target
Units that strictly require a configured network connection should pull in network-online.target (via a Wants= type dependency) and order themselves after it. This target unit is intended to pull in a service that delays further execution until the network is sufficiently set up. What precisely this requires is left to the implementation of the network managing service.

multi-user.target
A special target unit for setting up a multi-user system (non-graphical). This is pulled in by graphical. Units that are needed for a multi-user system shall add Wants= dependencies for their unit to this unit during installation. This is best configured via WantedBy=multi-user.target in the unit's [Install] section.

graphical.target
A special target unit for setting up a graphical login screen. This pulls in multi-user.target. Units that are needed for graphical logins shall add Wants= dependencies for their unit to this unit (or multi-user.target) during installation. This is best configured via WantedBy=graphical.target in the unit's [Install] section.

cpprust
  • 211
  • 1
  • 3