# nfsmount failing

## psilo357

I am having trouble getting some nfs shares on my freenas server to automount at boot. It always fails DNS resoluion...here is what is in my fstab for mounting the nfs share:

```

    192.168.1.115:/mnt/Disk0   /media/disk0   nfs   defaults   0 0

```

and here is my rc.log from startup showing the failure:

```

    * Caching service dependencies ...

    [ ok ]

    avahi-daemon         | * Starting avahi-daemon ...                       [ ok ]

    portmap              | * Starting portmap ...                                   [ ok ]

    urandom              | * Initializing random number generator ...     [ ok ]

    dhcdbd               | * Starting dhcdbd ...                                      [ ok ]

    system-tools-backends| * Starting system-tools-backend ...         [ ok ]

    swap                 | * Activating swap devices ...                            [ ok ]

    syslog-ng            | * Starting syslog-ng ...                                     [ ok ]

    fbcondecor           | * Setting framebuffer console images ...         [ ok ]

    mdadm                | * Starting mdadm monitor ...                          [ ok ]

    NetworkManager       | * Starting NetworkManager ...                     [ ok ]

    vixie-cron           | * Starting vixie-cron ...                                    [ ok ]

    cupsd                | * Starting cupsd ...                                             [ ok ]

    rpc.statd            | * Starting NFS statd ...                                       [ ok ] 

    nfsmount             | * Starting NFS sm-notify ...                              [ ok ]

    nfsmount             | * Mounting NFS filesystems ...                           [ ok ]

    nfsmount             |mount.nfs: DNS resolution failed for 192.168.1.115: Name or service not known

    nfsmount             | * ERROR: nfsmount failed to start                      [ !! ]

    nfs                  | * Starting NFS mountd ...                                       [ ok ]

    samba                | * samba -> start: smbd ...                                    [ ok ]

    nfs                  | * Starting NFS daemon ...                                       [ ok ]

    nfs                  | * Starting NFS smnotify ...                                        [ ok ]

    netmount             | * Mounting network filesystems ...                        [ ok ]

    netmount             |mount.nfs: DNS resolution failed for 192.168.1.115: Name or service not known

    netmount             | * Could not mount all network filesystems               [ !! ]

    alsasound            | * Loading ALSA modules ...                                      [ ok ]

    alsasound            | *   Loading: snd-pcm-oss ...                                      [ ok ]

    alsasound            | *   Loading: snd-seq-oss ...                                      [ ok ]

    alsasound            | * Restoring Mixer Levels ...                                       [ ok ]

    samba                | * samba -> start: nmbd ...                                          [ ok ]   

    local                | * Starting local ...                                                       [ ok ]

```

It looks like things may be starting in the wrong order possibly, or that the network is not up and running by the time i try to mount the NFS shares, either way, i don't know how to fix it. Also, instead of using the ip for the shares, would it be possible to use

```

    freenas:/mnt/Disk0   /media/disk0   nfs   defaults   0 0

```

since that is its name? It works when i mount from command line after all booted up and everything using that...

any insight into the problem would be great...

thanks

----------

## Raniz

It's probably because you're using networkmanager. When starting using the regular net.* scripts init waits until an IP address has been acquired, this is not the case with networkmanager.

Look in the configuration for the networkmanager script if you can make it wait.

----------

## psilo357

ok, so would this be in a configuration setting, or in the init script itself?  Also, if in the script, how to make it wait until it gets IP's?

thanks

----------

## psilo357

here is teh code of the init script

/etc/init.d/NetworkManager

```

#!/sbin/runscript

# Copyright (c) 2008 Saleem Abdulrasool <compnerd@compnerd.org>

# Distributed under the terms of the GNU General Purpose License v2

# $Header: $

depend() {

   need hald

}

start() {

   ebegin "Starting NetworkManager"

   start-stop-daemon --start --quiet --pidfile /var/run/NetworkManager.pid \

      --exec /usr/sbin/NetworkManager -- --pid-file /var/run/NetworkManager.pid

   eend $?

}

stop() {

   ebegin "Stopping NetworkManager"

   start-stop-daemon --stop --quiet --pidfile /var/run/NetworkManager.pid

   eend $?

}

```

Im not sure what quiet does, all it says on the initscript page in the handbook is that its not recommended, as it may hinder debugging, im going to remove it and see if it really helps at all...

any other help or info on how to fix this would be great.

----------

## psilo357

So, working through this some more, i found I do not really need nfsmount at all, since netmount is doing the same thing, both were failing, but no need to do the same tasks twice, so i have now removed nfsmount from default.  Also, i have figured out that by adding a sleep of about 10 seconds to the netmount start() script, it works fine.  i did put NetworkManager as one of the 'needs' in the depends() section, but it would still fail...here is the code for netmount with my added sleep in start()

```

#!/sbin/runscript

# Copyright 2007-2008 Roy Marples <roy@marples.name>

# All rights reserved. Released under the 2-clause BSD license.

description="Mounts network shares according to /etc/fstab."

need_portmap()

{

   local opts=

   local IFS="

"

   set -- $(fstabinfo --options --fstype nfs,nfs4)

   for opts; do

      case ,${opts}, in

         *,noauto,*|*,nolock,*);;

         *) return 0;;

      esac

   done

   return 1

}

depend()

{

   # Only have portmap as a dependency if there is a nfs mount in fstab

   # that is set to mount at boot

   local pmap=

   if need_portmap; then

      pmap="rpc.statd"

      [ -x /etc/init.d/rpcbind ] \

         && pmap="${pmap} rpcbind" \

         || pmap="${pmap} portmap"

   fi

   config /etc/fstab

   need net NetworkManager ${pmap}

   use afc-client amd autofs openvpn

   use dns nfs nfsmount portmap rpcbind rpc.statd rpc.lockd

   keyword nojail noprefix novserver

}

start()

{   

   local myneed= myuse= pmap="portmap" nfsmounts=

   [ -x /etc/init.d/rpcbind ] && pmap="rpcbind"

   local x= fs=

   for x in ${net_fs_list}; do

      case "${x}" in

         nfs|nfs4)

         # If the nfsmount script took care of the nfs

         # filesystems, then there's no point in trying

         # them twice

         service_started nfsmount && continue

         # Only try to mount NFS filesystems if portmap was

         # started. This is to fix "hang" problems for new

         # users who do not add portmap to the default runlevel.

         if need_portmap && ! service_started "${pmap}"; then

            continue

         fi

         ;;

      esac

      fs="${fs}${fs:+,}${x}"

   done

   sleep 10

   ebegin "Mounting network filesystems"

   mount -at ${fs}

   ewend $? "Could not mount all network filesystems"

   return 0

}

stop()

{

   local x= fs=

   ebegin "Unmounting network filesystems"

   . "${RC_LIBDIR}/sh/rc-mount.sh"

   for x in ${net_fs_list}; do

      fs="${fs}${fs:+,}${x}"

   done

   if [ -n "${fs}" ]; then

      umount -at ${fs} || eerror "Failed to simply unmount filesystems"

   fi

   eindent

   fs=

   for x in ${net_fs_list}; do

      fs="${fs}${fs:+|}${x}"

   done

   [ -n "${fs}" ] && fs="^(${fs})$"

   do_unmount "umount" ${fs:+--fstype-regex} ${fs} --netdev

   retval=$?

   eoutdent

   eend ${retval} "Failed to unmount network filesystems"

}

```

So this fixes my problem for now.  However, I do not really like this fix, as using a sleep is just bad practice....seems that even though NetworkManager is reporting its complete, even though the network is not ready, I would like to do this the right way if anyone has an idea on how to do so...my main question:

How do I detect that the network is up and ready before attempting the mount?  even though NetworkManager reports it is ready, not everything is, hence why the sleep solves the problem...

any help is appreciated.

----------

## Raniz

Check the docs for networkmanager, it's possible that you can execute scripts on successful connection, I know that Wicd can do that.

----------

