Ubuntu – samba not starting from systemctl: timeout

sambasystemd

I attempting to set up a samba server on an ubuntu server (18.04). I needed to compile from sources since I need special support for Mac OS and time machine is which is available only in versions 4.8 or above.

I tried installing 4.9.2 and followed the instructions here with the exception that I needed to disable LDAP and AD support for configure. The build and install went fine so I copied the systemctl files into place and tried to start everything.

super@fulton:~/samba/samba-samba-4.9.2$ sudo systemctl start {nmb,smb,winbind}.service
Job for nmb.service failed because a timeout was exceeded.
See "systemctl status nmb.service" and "journalctl -xe" for details.
Job for winbind.service failed because a timeout was exceeded.
See "systemctl status winbind.service" and "journalctl -xe" for details.
Job for smb.service failed because a timeout was exceeded.
See "systemctl status smb.service" and "journalctl -xe" for details.

status gives:

‚óŹ smb.service - Samba SMB Daemon
   Loaded: loaded (/lib/systemd/system/smb.service; enabled; vendor preset: enabled)
   Active: failed (Result: timeout) since Thu 2019-01-31 14:46:34 NZDT; 13min ago
     Docs: man:smbd(8)
           man:samba(7)
           man:smb.conf(5)
  Process: 12343 ExecStart=/usr/sbin/smbd --foreground --no-process-group $SMBDOPTIONS (code=killed, signal=TERM)
 Main PID: 12343 (code=killed, signal=TERM)

Jan 31 14:45:04 fulton.geek.nz systemd[1]: Starting Samba SMB Daemon...
Jan 31 14:46:34 fulton.geek.nz systemd[1]: smb.service: Start operation timed out. Terminating.
Jan 31 14:46:34 fulton.geek.nz systemd[1]: smb.service: Failed with result 'timeout'.
Jan 31 14:46:34 fulton.geek.nz systemd[1]: Failed to start Samba SMB Daemon.

But /var/log/samba/log.smbd suggests that the services started.

[2019/01/31 14:45:04.465362,  0] ../lib/util/become_daemon.c:138(daemon_ready)
  daemon_ready: STATUS=daemon 'smbd' finished starting up and ready to serve connections

so it looks as if there is something wrong with the systemd script and it is killing off the process when it does not get some expected response.

Any ideas what to look for?

update: I was successfully able to start smbd from the command line and attach to shared which suggest that there is an issue with the systemd script. I note that smbd is invoked with the –foreground is this correct? I guess systemd intends to background the process itself so it can manage it?

here is the config:

[Unit]
Description=Samba SMB Daemon
Documentation=man:smbd(8) man:samba(7) man:smb.conf(5)
Wants=network-online.target
After=network.target network-online.target nmb.service winbind.service

[Service]
Type=notify
NotifyAccess=all
PIDFile=/var/run/samba/smbd.pid
LimitNOFILE=16384
EnvironmentFile=-/etc/sysconfig/samba
ExecStart=/usr/sbin/smbd --foreground --no-process-group $SMBDOPTIONS
ExecReload=/bin/kill -HUP $MAINPID
LimitCORE=infinity

[Install]
WantedBy=multi-user.target

Best Answer

I ran into this when trying to get different types of machines running the latest version of Samba for time machine use as well.

One solution is to change the Type=notify to Type=simple. There is something about the new versions of Samba not playing nice with the way systemd handles process communication.

-Type=notify
+Type=simple

Then run systemctl daemon-reload and try to start er up again.

Related Question