Ubuntu

nmbd fails to start on boot - problem with upstart

Reported by Abhishek Mukherjee on 2010-06-18
82
This bug affects 12 people
Affects Status Importance Assigned to Milestone
samba (Ubuntu)
Medium
Jelmer Vernooij
Lucid
Undecided
Unassigned
Maverick
Medium
Chuck Short

Bug Description

Binary package hint: samba

1. Release of Ubuntu is 10.04 LTS
2. Version of Samba is - 3.4.7

Problem - Expected nmbd service to start at boot but it failed to start at boot. We have multiple systems but this problem has been noticed only on certain systems. The same packages were installed on all systems. As a workaround, we changed the pre start script configuration file for nmbd - /etc/init/nmbd.conf to make it start at boot always. The following 2 lines were commented in the nmbd.conf file -

        NMBD_DISABLED=`testparm -s --parameter-name='disable netbios' 2>/dev/null`
       [ "x$NMBD_DISABLED" = xYes ] && { stop; exit 0; }

I don't think that I understand what the second line is trying to do. Please check and advise how to fix this problem.

Related branches

Download full text (12.2 KiB)

No manual changes were made to samba configuration file. Here it goes.

#
# Sample configuration file for the Samba suite for Debian GNU/Linux.
#
#
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options most of which
# are not shown in this example
#
# Some options that are often worth tuning have been included as
# commented-out examples in this file.
# - When such options are commented with ";", the proposed setting
# differs from the default Samba behaviour
# - When commented with "#", the proposed setting is the default
# behaviour of Samba but the option is considered important
# enough to be mentioned here
#
# NOTE: Whenever you modify this file you should run the command
# "testparm" to check that you have not made any basic syntactic
# errors.
# A well-established practice is to name the original file
# "smb.conf.master" and create the "real" config file with
# testparm -s smb.conf.master >smb.conf
# This minimizes the size of the really used smb.conf file
# which, according to the Samba Team, impacts performance
# However, use this with caution if your smb.conf file contains nested
# "include" statements. See Debian bug #483187 for a case
# where using a master file is not a good idea.
#

#======================= Global Settings =======================

[global]

## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = WORKGROUP

# server string is the equivalent of the NT Description field
   server string = %h server (Samba, Ubuntu)

# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable its WINS Server
# wins support = no

# WINS Server - Tells the NMBD components of Samba to be a WINS Client
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
; wins server = w.x.y.z

# This will prevent nmbd to search for NetBIOS names through DNS.
   dns proxy = no

# What naming service and in what order should we use to resolve host names
# to IP addresses
; name resolve order = lmhosts host wins bcast

#### Networking ####

# The specific set of interfaces / networks to bind to
# This can be either the interface name or an IP address/netmask;
# interface names are normally preferred
; interfaces = 127.0.0.0/8 eth0

# Only bind to the named interfaces and/or networks; you must use the
# 'interfaces' option above to use this.
# It is recommended that you enable this feature if your Samba machine is
# not protected by a firewall or is a firewall itself. However, this
# option cannot handle dynamic or non-broadcast interfaces correctly.
; bind interfaces only = yes

#### Debugging/Accounting ####

# This tells Samba to use a separate log file for each machine
# that connects
   log file = /var/log/samba/log.%m

# Cap the size of the individual log files (in KiB).
   max log size = 1000

# If you want Samba to only log through syslog then set the following
# parameter to 'yes'.
# syslog only = no

# We want Samba to log a minimum amount of informat...

Thierry Carrez (ttx) wrote :

Those two lines are about checking if NetBIOS is disabled in smb.conf, and if yes, not start nmbd.
If it works reliably for you once you comment those lines, something must fail on this testparm check.

Could you try running the following (on one of the machines that fail if the check is enabled):
$ testparm -s --parameter-name='disable netbios' 2>/dev/null
$ echo $?

Also, on the machine that fail to start nmbd at boot, does starting up nmbd manually after boot (sudo start nmbd) work with an uncommented prestart script ?

Changed in samba (Ubuntu):
importance: Undecided → Medium
status: New → Incomplete
aroonsurya (aroonsurya) wrote :

I and Abhishek are working in the same lab setup.
Here are the answers to U'r Q

$ testparm -s --parameter-name='disable netbios' 2>/dev/null
$ echo $?

rka-29@rka-29-desktop:~$ testparm -s --parameter-name='disable netbios' 2>/dev/null
No
rka-29@rka-29-desktop:~$ echo $?
0

Also, on the machine that fail to start nmbd at boot, does starting up nmbd manually after boot (sudo start nmbd) work with an uncommented prestart script ?

Yes.

Thierry Carrez (ttx) wrote :

OK, so the issue seems to be that << testparm -s --parameter-name='disable netbios' >> sometimes fails (or returns 'Yes') when started at boot-time. The "start on (local-filesystems and net-device-up IFACE!=lo)" should however be late enough...

To confirm, could you try with:

pre-start script
  date > /tmp/nmbd-upstart.log
  NMBD_DISABLED=`testparm -s --parameter-name='disable netbios' 2>>/tmp/nmbd-upstart.log`
  echo "Output is $NMBD_DISABLED" >> /tmp/nmbd-upstart.log
  [ "x$NMBD_DISABLED" = xYes ] && { stop; exit 0; }
  install -o root -g root -m 755 -d /var/run/samba
end script

And post the resulting /tmp/nmbd-upstart.log when it fails ?

Bret Towe (magnade) wrote :

I played with the nmbd.conf script and changed the 2 lines that seem at fault
looks to of worked not done repeat tests

NMBD_DISABLED=`testparm -s --parameter-name="disable netbios" 2>>/tmp/nmbd-upstart.log`
[ "$NMBD_DISABLED" = Yes ] && { stop; exit 0; }

I don't think removing the x's from the second line is required but it looks better

aroonsurya (aroonsurya) wrote :

Here is the log

Sat Jun 26 17:31:19 IST 2010
Load smb config files from /etc/samba/smb.conf
rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)
Processing section "[printers]"
Processing section "[print$]"
Loaded services file OK.
Output is No

There is something interesting that happened after we changed the script the way you had described. NMBD started at boot. After some troubleshooting, we noticed the following errors in the /tmp/nmbd-upstart.log

$ cat /tmp/nmbd-upstart.log
Load smb config files from /etc/samba/smb.conf
rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)
Processing section "[printers]"
Processing section "[print$]"
Loaded services file OK.
ERROR: lock directory /var/run/samba does not exist
ERROR: pid directory /var/run/samba does not exist

This was only after we removed the date command, if I remember correctly. But the crux of the issue is that a race condition is stopping nmbd from starting. It so happens that samba and nmbd start up at the same time. The directory /var/run/samba is created by the samba service when its starting up. But samba service does that only after the command "testparm -s --parameter-name='disable netbios' 2>>/tmp/nmbd-upstart.log" has executed unsuccessfully. NMBD service stopped failing when we added date command in the script. The date command must have introduced the much needed delay which we couldn't introduce with the "sleep 20" command. However we created the directory before the execution of the "testparm" command execution and that fixed the issue. This race condition should ideally be avoided by forcing nmbd to start up only after samba service has started successfully. I don't know how to do that in an upstart script. Please guide.

At present the pre start section of the script looks like this -

pre-start script
# No need to keep it now
# date > /tmp/nmbd-upstart.log

# Introduced mkdir to fix race condition
 mkdir /var/run/samba
 NMBD_DISABLED=`testparm -s --parameter-name='disable netbios' 2>/tmp/nmbd-upstart.log`
 [ "x$NMBD_DISABLED" = xYes ] && { stop; exit 0; }
 install -o root -g root -m 755 -d /var/run/samba
end script

Thierry Carrez (ttx) wrote :

Nice investigation, thanks!
nmbd would only start when its "start" is run after smbd's upstart script "pre-start". We indeed need to fix that race.

Changed in samba (Ubuntu):
importance: Medium → High
status: Incomplete → Triaged
Chuck Short (zulcss) wrote :

Hi,

Can you test out samba_3.4.7~dfsg-1ubuntu4~test in https://edge.launchpad.net/~zulcss/+archive/server-bug-fixes when it gets built?

Thanks
chuck

Hi Chuck,

 Sure, we can test it. Please let us know where from we can download the
package once it has been built.

Thanks,
Abhishek

On Fri, Jul 2, 2010 at 6:24 PM, Chuck Short <email address hidden>wrote:

> Hi,
>
> Can you test out samba_3.4.7~dfsg-1ubuntu4~test in
> https://edge.launchpad.net/~zulcss/+archive/server-bug-fixes<https://edge.launchpad.net/%7Ezulcss/+archive/server-bug-fixes>when it
> gets built?
>
> Thanks
> chuck
>
> --
> nmbd fails to start on boot - problem with upstart
> https://bugs.launchpad.net/bugs/596064
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in “samba” package in Ubuntu: Triaged
>
> Bug description:
> Binary package hint: samba
>
> 1. Release of Ubuntu is 10.04 LTS
> 2. Version of Samba is - 3.4.7
>
> Problem - Expected nmbd service to start at boot but it failed to start at
> boot. We have multiple systems but this problem has been noticed only on
> certain systems. The same packages were installed on all systems. As a
> workaround, we changed the pre start script configuration file for nmbd -
> /etc/init/nmbd.conf to make it start at boot always. The following 2 lines
> were commented in the nmbd.conf file -
>
> NMBD_DISABLED=`testparm -s --parameter-name='disable netbios'
> 2>/dev/null`
> [ "x$NMBD_DISABLED" = xYes ] && { stop; exit 0; }
>
> I don't think that I understand what the second line is trying to do.
> Please check and advise how to fix this problem.
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/ubuntu/+source/samba/+bug/596064/+subscribe
>

michael brenden (mike-brenden) wrote :

Haven't seen any race condition here yet. Problem here was "testparm" is somehow missing from PATH (and entire system)...but that's its own problem. What's annoying is that Upstart reported error 127 in /var/log/daemon.log - not obvious enough. IMO if a pre-script command bombs, as in trying to run a non-existant file, it should sure be obvious to point the finger to the real culprit. Upstart is already the unfortunate flak-catcher-target for decades of messy sysV init script grunge, and so we'd all understand (and benefit) if it did its part to redirect the causes and pains to where best deserved. Thank you for great software, much needed, too.

MURAKAMI (lev-murakami) wrote :

I experienced this (nmbd do not startup at boot), recently after upgrading from ubuntu 9.10 server to 10.04 LTS.

The solution suggested in the Post#7 by Mr Abhishek Mukherjee worked.
(Just adding the line "mkdir /var/run/samba" at just after the "pre-start script" line of /etc/init/nmbd.conf)

Regards.

Thierry Carrez (ttx) wrote :

Should probably be lumped together with bug 572410

Changed in samba (Ubuntu Lucid):
assignee: nobody → Chuck Short (zulcss)
Dunkirk (david-davidkrider) wrote :

I tested what my /etc/init/nmbd.conf was doing at the command line:

---
root@server2:/var/log# /usr/bin/testparm -s --parameter-name='disable netbios'
Load smb config files from /etc/samba/smb.conf
rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)
Processing section "[netlogon]"
Processing section "[profiles]"
Processing section "[homes]"
Processing section "[users]"
Processing section "[groups]"
Processing section "[pdf]"
Processing section "[printers]"
Processing section "[print$]"
.
.
.
Loaded services file OK.
ERROR: the 'unix password sync' parameter is set and there is no valid 'passwd program' parameter.
No
---

I simply got rid of the 'unix password sync' option in my smb.conf file (I wasn't really using it anyway), and everything started working again. Seems like any error in the Samba config is causing an exit code from testparm that's throwing off the stack of scripts that controls starting the process.

Thierry Carrez (ttx) on 2010-08-26
Changed in samba (Ubuntu):
assignee: nobody → Chuck Short (zulcss)
importance: High → Medium
Changed in samba (Ubuntu Lucid):
assignee: Chuck Short (zulcss) → nobody
Thierry Carrez (ttx) on 2010-09-02
tags: added: server-mrs
Chuck Short (zulcss) wrote :

I havent been able to reproduce this on maverick yet.

chuck

Dave Walker (davewalker) wrote :

@Chuck, were you able to reproduce it on Lucid? Do you consider this was Fix Released for Maverick, somewhere along the cycle?

I can reproduce it on Lucid and Maverick under the following conditions:

 - the network is a WLAN
 - the connection is made by Network Manager or WICD

I don't know what the condition "net-device-up IFACE!=lo" in /etc/init/nmbd.conf is really needed for. Can it be recommended to leave it out and to change the line to "start on local-filesystems", as it is in /etc/init/smbd.conf? Could that leed to some inconveniences?

A workaround is a post-connection script in WICD with the command "service nmbd start".

Jelmer Vernooij (jelmer) wrote :

It looks like the creation of /var/run/samba should happen earlier in the script.

What about the attached patch?

Jelmer Vernooij (jelmer) wrote :

What appears to be happening is that the first time nmbd gets run testparm fails (because pid dir /var/run/samba doesn't exist yet) so nmbd is not started.

After that smbd gets run and its pre-init will create /var/run/samba. So the next time nmbd's pre-init script will work.

Jean-Michel Dault (jmdault) wrote :

It should be:
        mkdir -p /var/run/samba

Otherwise if the directory already exists it won't be able to start. So mkdir -p will start in all conditions.

On Fri, 2010-12-10 at 20:52 +0000, Jean-Michel Dault wrote:
> It should be:
> mkdir -p /var/run/samba
>
> Otherwise if the directory already exists it won't be able to start. So
> mkdir -p will start in all conditions.
I'm pretty sure "install -d" exits with success if the directory already
exists, too.

Cheers,

Jelmer

Jelmer Vernooij (jelmer) on 2011-01-25
Changed in samba (Ubuntu):
assignee: Chuck Short (zulcss) → Jelmer Vernooij (jelmer)
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package samba - 2:3.5.6~dfsg-4ubuntu2

---------------
samba (2:3.5.6~dfsg-4ubuntu2) natty; urgency=low

  * debian/samba.nmbd.upstart: create /var/run/samba directory before running
    testparm. Fixes start-up of nmb after boot. (LP: #596064)
    Thanks to Jelmer Vernooij.
 -- Chuck Short <email address hidden> Tue, 25 Jan 2011 10:09:33 -0500

Changed in samba (Ubuntu):
status: Triaged → Fix Released
Kylepablo (kylepablo) wrote :

This bug is still present for me. I have to do nmbd -D manually.

Ubuntu 10.10
samba 2:3.5.4~dfsg-1ub

nmbd.conf is attached.

Kylepablo (kylepablo) wrote :

Confirmed. Adding mkdir -p /var/run/samba just after the "pre-start script" line of /etc/init/nmbd.conf fixes it.

Ubuntu 10.10
samba 2:3.5.4~dfsg-1ub

giox069 (giodev) wrote :

I'm using a wireless connection with wicd (wlan interface is wlan0). Adding mkdir -p /var/run/samba does not solve the problem.
Changing
  start on (local-filesystems and net-device-up IFACE!=lo)
to
  start on (local-filesystems)
in /etc/init/nmbd.conf fixes it and nmbd starts. But this is not the right way to fix it, because there are other services which depends on "net-device-up".

I think it's wicd not emitting "net-device-up" when my wlan0 comes up. But... how can I check/confirm it ?

Jelmer Vernooij (jelmer) wrote :

Hi giox069,

That's a different issue than this bug (which is already fixed). Can you please file a separate bug report about that?

Jelmer Vernooij (jelmer) wrote :

Kylepablo, this bug was fixed in 2:3.5.6~dfsg-4ubuntu2, so a version newer than what you are running.

giox069 (giodev) wrote :

@Jelmer: ok, I will do further investigation on how wicd works and then file a separate bug report.

Paul Tansom (aptanet) wrote :

Is there a fix for 10.04 LTS, which only runs 2:3.4.7~dfsg-1ubuntu3.4? I don't often reboot my server, but invariably forget to check that nmbd is running when I do!

Jelmer Vernooij (jelmer) wrote :

On Sun, 2011-03-06 at 20:49 +0000, Paul Tansom wrote:
> Is there a fix for 10.04 LTS, which only runs 2:3.4.7~dfsg-1ubuntu3.4? I
> don't often reboot my server, but invariably forget to check that nmbd
> is running when I do!
There is no fix for Maverick yet, but according to the Launchpad page
Chuck will backport a fix to Maverick.

Cheers,

Jelmer

Still happening in natty amd64

I have to start nmbd manually for full network share (load and access)...

using the mkdir -p fix did not resolve...

Jelmer Vernooij (jelmer) wrote :

On Sun, 2011-03-27 at 18:23 +0000, Cypher2 wrote:
> Still happening in natty amd64
>
> I have to start nmbd manually for full network share (load and
> access)...
>
> using the mkdir -p fix did not resolve...
I suspect you're hitting a different issue, please file a separate bug report.

Cheers,

Jelmer

actually no.. same issue: when i start the system, only smbd is loaded as
process. when looking at /var/run/samba it is active and populated with no
nmbd PID file. only when I switch to console and run 'sudo start nmbd' that
it loads a process and assigns PID to it.

when I restart or shutdown system and boot again.. nmbd isn't there anymore

I fixed the nmbd startup issue on natty and maverick!

It has to do with the init scrip at /etc/init/nmbd.conf

The start line needs to state start on local-filesystems ONLY!

The loopback ethernet interfaces start too late to satisfy the chronological dependency for nmbd to load as process...

Jelmer Vernooij (jelmer) wrote :

Please open a different bug report; although it's related, it's a different issue.

Nice catch, btw.

oki doki, bug registered as #750786 for natty!

Changed in samba (Ubuntu Lucid):
status: New → Confirmed

Geez, isn' t there a META issue function in launchpad?
nmbd doesn' t startup since 9.04, and now trying to really fix it, without rc.local delayed work arounds, I found a fix for each version of Ubuntu server. Bugs since 2009.

Anyone know why the samba init.d got split up into smbd and nmbd? It all worked when it was just samba.

I just hit this bug, after updating samba to start after eth0 was up because of bug
https://bugs.launchpad.net/ubuntu/+source/samba/+bug/823878

dylan@strut-google-server:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04.3 LTS"
dylan@strut-google-server:~$ cat /tmp/upstart-nmbd.log
Load smb config files from /etc/samba/smb.conf
rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)
Processing section "[Strut Share]"
Processing section "[printers]"
Processing section "[print$]"
Loaded services file OK.
ERROR: lock directory /var/run/samba does not exist
ERROR: pid directory /var/run/samba does not exist
dylan@strut-google-server:~$

Vasya Pupkin (shadowlmd) wrote :

Few days ago nmbd stopped starting on boot for me. I did not change anything at all.

===
user@host:~$ cat /etc/init/nmbd.conf
description "NetBIOS name server"
author "Steve Langasek <email address hidden>"

start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [!2345]

expect fork
respawn

pre-start script
        NMBD_DISABLED=`testparm -s --parameter-name='disable netbios' 2>/dev/null`

        [ "x$NMBD_DISABLED" = xYes ] && { stop; exit 0; }

        install -o root -g root -m 755 -d /var/run/samba
end script

exec nmbd -D
===

This was working fine since I changed "start on" thing as described in https://bugs.launchpad.net/ubuntu/+source/samba/+bug/823878 bug.

I have nothing in logs that could give me a single hint why it's not starting. This bug is obviously not fixed.

Vasya Pupkin (shadowlmd) wrote :

Also, sometimes it starts, sometimes not.

Vasya Pupkin (shadowlmd) wrote :

I added some debug into /etc/init/nmbd.conf so it looks like this:

===
description "NetBIOS name server"
author "Steve Langasek <email address hidden>"

start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [!2345]

expect fork
respawn

pre-start script
        NMBD_DISABLED=`testparm -s --parameter-name='disable netbios' 2>/dev/null`
        echo `date` $NMBD_DISABLED >/tmp/upstart-nmdb.log

        [ "x$NMBD_DISABLED" = xYes ] && { stop; exit 0; }

        install -o root -g root -m 755 -d /var/run/samba
end script

exec nmbd -D
===

I was suspecting testparm to return something wrong, but instead, when I rebooted few times and nmbd didn't start again, I didn't even have /tmp/upstart-nmdb.log file which means it didn't hit pre-start script section. I have no idea how can that be. Both smbd.conf and nmbd.conf have "start on (local-filesystems and net-device-up IFACE=eth0)", but somehow first gets started and second doesn't.

Vasya Pupkin (shadowlmd) wrote :

Changing to start on (local-filesystems) did not help, still not starting.

Vasya Pupkin (shadowlmd) wrote :

Some more testing revealed that if I comment out user's cron @reboot job that starts two virtualbox machines, nmbd starts. So I guess upstart fails to continue starting daemons if there is a high system load at boot time.

This makes me very sad. User job can affect server's start up... I have these virtual machines since 2009 but only few days ago it started to happen, so I blame latest kernel update.

Vasya Pupkin (shadowlmd) wrote :

Yesterday after reboot neither smbd, nor nmbd started. There was nothing in logs. Ubuntu server is such a failure.

Vasya Pupkin (shadowlmd) wrote :

After another reboot, smbd started, nmbd didn't, but this time there was a message in log:

May 18 18:27:37 shadow-server init: nmbd pre-start process (882) terminated with status 1

After one more reboot both smbd and nmbd startd. Can someone finally fix this? Can this god damn init be more strict on starting services? And at least provide a good reason why some service did not start, like it is done in Windows for 15 years now?!

Vasya Pupkin (shadowlmd) wrote :

Can someone at least tell me how I can debug this? There is absolutely nothing in logs. nmbd just does not start even with "start on (local-filesystems)" sometimes. smbd starts, nmbd doesn't.

This bug affects me. I am running 10.04 (LTS) on an Oracle VM VirtualBox. I am also setting up a ipv6 tunnel with Hurricane Electric, so I am fiddling with /etc/NetworkManager/{interfaces, system-connections/'Auto eth1'} & /etc/network/interfaces.

Hello Customer

They look and feel exactly like the real thing.
Now you can afford expensive - and classy-looking watch to impress people with, just purchase top quality replica watch or some watches for different occasions. We don't offer cheap imitations. Our watches make you look rich and feel rich. Great selection of most popular brands and models!

****************************************
I got my watch couple days ago. I did like to thank to you first of all. The watch is fantastic and by the way thanks for the pen. It’s beautiful. I was very skeptical about buying things from the internet at the beginning but you changed my opinion. Now I know there are some serious business owners on the internet such as you. Great, reliable and on time service!
Bless
                     Rolando Dooley
****************************************

Click here ---> http://cumer.ru

Dan Corso (dancorso) wrote :

Hi guys,

try this... replace the "start on" line with:

start on (started smbd)

it tells upstart to respect priorities (worked for me).

Bye,
Daniele

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Bug attachments