大网数据广告活动
服务器运维问答

Samba daemon does not work as systemd service, but works in foreground

· 52CE 我爱测

I am running a fresh install of Ubuntu Server 16.04.1 and having troubles with smbd. service smbd status tells me that smbd should be running: ● smbd.service - LSB: start Samba SMB/CIFS daemon (smbd) Loaded: loaded (/etc/init.d/s…

问题原文

原帖链接 · Michael Kremser · CC BY-SA 3.0

I am running a fresh install of Ubuntu Server 16.04.1 and having troubles with smbd. service smbd status tells me that smbd should be running:

   ● smbd.service - LSB: start Samba SMB/CIFS daemon (smbd)
   Loaded: loaded (/etc/init.d/smbd; bad; vendor preset: enabled)
   Active: active (exited) since Die 2016-10-18 17:35:23 CEST; 2s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 24218 ExecStop=/etc/init.d/smbd stop (code=exited, status=0/SUCCESS)
  Process: 21980 ExecReload=/etc/init.d/smbd reload (code=exited, status=0/SUCCESS)
  Process: 25190 ExecStart=/etc/init.d/smbd start (code=exited, status=0/SUCCESS)

Okt 18 17:35:22 speedy systemd[1]: Starting LSB: start Samba SMB/CIFS daemon (smbd)...
Okt 18 17:35:23 speedy smbd[25190]:  * Starting SMB/CIFS daemon smbd
Okt 18 17:35:23 speedy smbd[25190]:    ...done.
Okt 18 17:35:23 speedy systemd[1]: Started LSB: start Samba SMB/CIFS daemon (smbd).

and this can be verified by ps axf | grep smbd:

25356 pts/2    S+     0:00  |   \_ grep --color=auto smbd
19915 ?        Ss     0:08      \_ /usr/sbin/smbd -D
19919 ?        S      0:00          \_ /usr/sbin/smbd -D

However, netstat -tpln | grep "smbd" returns nothing and also nmap shows "closed" on ports 139 and 445.

What I tried so far is activating these options in /etc/samba/smb.conf, but it doesn't help:

interfaces = enp2s0 bind interfaces only = true

If I start Samba in foreground using /usr/sbin/smbd -F, it works. I can then connect from another machine to the server and exchange files.

I have no clue that there might be wrong or how I could track down the problem.

Best regards,

Michael

已采纳解答

原帖链接 · Szász Eduárd István · CC BY-SA 3.0

Got the same issue, in my case the problem was that another issue of smbd was running in a docker container, which was detected by start-stop-daemon, so it wouldn't start the service. In this case, I've changed this line in the file /etc/init.d/smbd:

 if ! start-stop-daemon --start --quiet --oknodo --exec /usr/sbin/smbd -- -D ; then

to:

 if ! start-stop-daemon --start --quiet --oknodo --pidfile /var/run/samba/smbd.pid --exec /usr/sbin/smbd -- -D ; then

This way it starts smbd if it's pid file does not exist.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-10-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。