Which Systemd target should I use to start a service at boot but not delay user login

2

1

While running systemd-analyze critical-chain I noticed that the Samba daemon is on the path to user login. Although I would like Samba to start automatically on boot, I don't care if it happens before or after I log in.

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 @13.587s
└─multi-user.target @13.587s
  └─smbd.service @11.231s +2.355s
    └─network.target @11.230s
      └─netctl-auto@wlp4s0.service @10.302s +927ms
        └─basic.target @9.496s
          └─sockets.target @9.496s
            └─pcscd.socket @9.496s
              └─sysinit.target @9.461s
                └─systemd-timesyncd.service @9.397s +63ms
                  └─systemd-tmpfiles-setup.service @9.201s +128ms
                    └─local-fs.target @9.199s
                      └─windows.mount @8.396s +802ms
                        └─dev-disk-by-uuid-E200B0E200B0BF3B.device @8.362s

Taking a look at the unit file, it declares WantedBy=multi-user.target. I figured I could switch this target with some alternate target to get Samba off the critical path. However, I don't know which target to use.

systemctl cat smbd.service
# /usr/lib/systemd/system/smbd.service
[Unit]
Description=Samba SMB/CIFS server
After=network.target nmbd.service winbindd.service

[Service]
Type=forking
PIDFile=/var/run/smbd.pid
ExecStart=/usr/bin/smbd -D
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

Huckle

Posted 2016-01-03T21:11:40.907

Reputation: 376

Answers

0

While researching and writing up the question, I ran systemctl --all to look through the available targets. I noticed that getty.target had a description of "Login Prompts". Taking a look at the critical path of getty.target showed that it actually starts before smbd because they do not rely on each other. So I just misinterpreted what multi-user.target meant.

My windows partition is now on the chopping block, haven't used it in ages.

getty.target @10.322s
└─getty@tty1.service @10.322s
  └─systemd-user-sessions.service @9.526s +785ms
    └─basic.target @9.496s
      └─sockets.target @9.496s
        └─pcscd.socket @9.496s
          └─sysinit.target @9.461s
            └─systemd-timesyncd.service @9.397s +63ms
              └─systemd-tmpfiles-setup.service @9.201s +128ms
                └─local-fs.target @9.199s
                  └─windows.mount @8.396s +802ms
                    └─dev-disk-by-uuid-E200B0E200B0BF3B.device @8.362s

Huckle

Posted 2016-01-03T21:11:40.907

Reputation: 376