# NFS issue

## m_gustafsson

Hi!

I have exported a disk to some computers on my intranet:

```
$ cat /etc/exports

# /etc/exports: NFS file systems being exported.  See exports(5).

/home desktop1(async,rw)

/home server2(async,rw,all_squash,anonuid=1000,anongid=1000)

/home matsx60s(async,rw,all_squash,anonuid=1000,anongid=1000)
```

If I now reboot the "server" and then try to mount the disk on the other computers then I get permission denied.

But, if I on the server, after reboot, run:

```
# /etc/init.d/portmap restart
```

then the mounting on the other computers goes just fine.

The server has reiserfs file system while the others have EXT3 (if that could matter).

What could be my problem?

Thanks.

----------

## eccerr0r

only a guess: how are you resolving the hostnames?  Are you using /etc/hosts or depending on DNS?

and also: Is portmapper running fine on startup?

My NFS server seems to work fine, but I use dotted quad notation and host masks to specify hosts.

----------

## m_gustafsson

Thanks for your help.

I am using /etc/hosts to resolve the hostnames.

How do I check if portmapper is running fine at startup, I can't remember that I have seen any strange messages when booting.

If I look into /var/log/messages for portmap I see:

```
# cat /var/log/messages | grep portmap

...

Jan 29 18:42:12 server1 kernel: RPC: failed to contact portmap (errno -101).

Jan 29 18:42:12 server1 kernel: portmap: RPC call returned error 101

Jan 29 18:42:12 server1 kernel: RPC: failed to contact portmap (errno -101).

Jan 29 18:42:12 server1 kernel: portmap: RPC call returned error 101

Jan 29 18:42:12 server1 kernel: RPC: failed to contact portmap (errno -101).

Feb  5 06:55:12 server1 kernel: RPC: failed to contact portmap (errno -5).

Feb 20 22:11:12 server1 kernel: RPC: failed to contact portmap (errno -5).

Feb 20 22:14:38 server1 kernel: RPC: failed to contact portmap (errno -5).

Feb 20 22:53:19 server1 kernel: RPC: failed to contact portmap (errno -5).

Feb 20 23:03:54 server1 kernel: RPC: failed to contact portmap (errno -5).

Mar 18 14:09:39 server1 kernel: RPC: failed to contact portmap (errno -5).

Mar 20 20:20:51 server1 kernel: RPC: failed to contact portmap (errno -5).

Aug  6 11:17:37 server1 kernel: RPC: failed to contact portmap (errno -5).
```

but those error messages seems to be quite old, as I did a reboot today.

----------

## Hu

What is the output of rc-update show -v on the NFS server?

----------

## gentoo_ram

On the server, you should be running /etc/init.d/nfs.  That will start all of the daemons necessary.  Looks like you're having an issue with portmapper.  If it's running correctly, you should see output like this:

```

serv:~> rpcinfo -p

   program vers proto   port

    100000    2   tcp    111  portmapper

    100000    2   udp    111  portmapper

    100024    1   udp  35069  status

    100024    1   tcp  47488  status

    100005    1   udp  59431  mountd

    100005    1   tcp  36522  mountd

    100005    2   udp  59431  mountd

    100005    2   tcp  36522  mountd

    100005    3   udp  59431  mountd

    100005    3   tcp  36522  mountd

    100021    1   udp  35681  nlockmgr

    100021    3   udp  35681  nlockmgr

    100021    4   udp  35681  nlockmgr

    100003    2   udp   2049  nfs

    100003    3   udp   2049  nfs

    100003    4   udp   2049  nfs

    100021    1   tcp  36050  nlockmgr

    100021    3   tcp  36050  nlockmgr

    100021    4   tcp  36050  nlockmgr

    100003    2   tcp   2049  nfs

    100003    3   tcp   2049  nfs

    100003    4   tcp   2049  nfs

```

On the client, you should be running /etc/init.d/netmount or /etc/init.d/nfsmount to start the needed programs.

----------

## m_gustafsson

This is what it all looks like now on the server:

```
# rc-update show -v

 * Broken runlevel entry: /etc/runlevels/default/xinetd

             apache2 |      default                  

             apcupsd |      default                  

            bootmisc | boot                          

             checkfs | boot                          

           checkroot | boot                          

               clock | boot                          

         consolefont | boot                          

         crypto-loop |                               

               cupsd |                               

            ddclient |      default                  

             dnsextd |                               

                 gpm |                               

            hostname | boot                          

             keymaps | boot                          

               local |      default nonetwork        

          localmount | boot                          

               mdnsd |                               

  mDNSResponderPosix |                               

             modules | boot                          

               mysql |      default                  

        mysqlmanager |                               

            net.eth0 |      default                  

              net.lo | boot                          

            netmount |      default                  

                 nfs |      default                  

            nfsmount |                               

                nscd |                               

                ntpd |      default                  

             numlock |                               

             openvpn |                               

             portmap |      default                  

           pydoc-2.5 |                               

           rmnologin | boot                          

          rpc.idmapd |                               

           rpc.statd |                               

              rsyncd |                               

               samba |      default                  

          slimserver |                               

      slimserver.old |                               

       squeezecenter |                               

                sshd |      default                  

            svnserve |      default                  

              svscan |      default                  

            sysklogd |      default                  

      udev-postmount |                               

             uptimed |      default                  

             urandom | boot                          

          vixie-cron |      default                  

                 xdm |                     
```

Could the "Broken runlevel entry..." be an issue?

```
# rpcinfo -p

   program vers proto   port

    100000    2   tcp    111  portmapper

    100000    2   udp    111  portmapper

    100024    1   udp  43547  status

    100024    1   tcp  49338  status

    100005    1   udp  58209  mountd

    100005    1   tcp  52026  mountd

    100005    2   udp  58209  mountd

    100005    2   tcp  52026  mountd

    100005    3   udp  58209  mountd

    100005    3   tcp  52026  mountd

    100021    1   udp  34591  nlockmgr

    100021    3   udp  34591  nlockmgr

    100021    4   udp  34591  nlockmgr

    100003    2   udp   2049  nfs

    100003    3   udp   2049  nfs

    100021    1   tcp  49303  nlockmgr

    100021    3   tcp  49303  nlockmgr

    100021    4   tcp  49303  nlockmgr

    100003    2   tcp   2049  nfs

    100003    3   tcp   2049  nfs
```

And on the client:

```
# rc-update show

 * Broken runlevel entry: /etc/runlevels/default/svscan

           alsasound | boot                          

             apcupsd |      default                  

            bootmisc | boot                          

             checkfs | boot                          

           checkroot | boot                          

               clock | boot                          

         consolefont | boot                          

               cupsd |      default                  

                dbus |      default                  

            hostname | boot                          

             keymaps | boot                          

               local |      default nonetwork        

          localmount | boot                          

             modules | boot                          

               mysql |      default                  

            net.eth0 |      default                  

              net.lo | boot                          

            netmount |      default                  

                ntpd |      default                  

             portmap |      default                  

           rmnologin | boot                          

               samba |      default                  

       squeezecenter |      default                  

                sshd |      default                  

            sysklogd |      default                  

             uptimed |      default                  

             urandom | boot                          

          vixie-cron |      default                  

                 xdm |      default                  

              xinetd |      default       
```

To me it looks ok, but maybe I should run the above on the server after a reboot? Now I ran it after restarting portmap and thus things are running as expected.

I will reboot and return with the results...

----------

## m_gustafsson

Now I did reboot my server and then ran:

```
# rc-update show -v

 * Broken runlevel entry: /etc/runlevels/default/xinetd

             apache2 |      default                  

             apcupsd |      default                  

            bootmisc | boot                          

             checkfs | boot                          

           checkroot | boot                          

               clock | boot                          

         consolefont | boot                          

         crypto-loop |                               

               cupsd |                               

            ddclient |      default                  

             dnsextd |                               

                 gpm |                               

            hostname | boot                          

             keymaps | boot                          

               local |      default nonetwork        

          localmount | boot                          

               mdnsd |                               

  mDNSResponderPosix |                               

             modules | boot                          

               mysql |      default                  

        mysqlmanager |                               

            net.eth0 |      default                  

              net.lo | boot                          

            netmount |      default                  

                 nfs |      default                  

            nfsmount |                               

                nscd |                               

                ntpd |      default                  

             numlock |                               

             openvpn |                               

             portmap |      default                  

           pydoc-2.5 |                               

           rmnologin | boot                          

          rpc.idmapd |                               

           rpc.statd |                               

              rsyncd |                               

               samba |      default                  

          slimserver |                               

      slimserver.old |                               

       squeezecenter |                               

                sshd |      default                  

            svnserve |      default                  

              svscan |      default                  

            sysklogd |      default                  

      udev-postmount |                               

             uptimed |      default                  

             urandom | boot                          

          vixie-cron |      default                  

                 xdm |          
```

And:

```
# rpcinfo -p

   program vers proto   port

    100000    2   tcp    111  portmapper

    100000    2   udp    111  portmapper

    100024    1   udp  43266  status

    100024    1   tcp  43074  status

    100005    1   udp  37738  mountd

    100005    1   tcp  56034  mountd

    100005    2   udp  37738  mountd

    100005    2   tcp  56034  mountd

    100005    3   udp  37738  mountd

    100005    3   tcp  56034  mountd

    100021    1   udp  52732  nlockmgr

    100021    3   udp  52732  nlockmgr

    100021    4   udp  52732  nlockmgr

    100003    2   udp   2049  nfs

    100003    3   udp   2049  nfs

    100021    1   tcp  53166  nlockmgr

    100021    3   tcp  53166  nlockmgr

    100021    4   tcp  53166  nlockmgr

    100003    2   tcp   2049  nfs

    100003    3   tcp   2049  nfs
```

The above still looks pretty ok to me...

While booting I got this message though:

```
# cat /var/log/syslog | grep nfs

Sep 13 10:02:02 server1 kernel: nfsd: last server has exited

Sep 13 10:02:02 server1 kernel: nfsd: unexporting all filesystems

Sep 13 10:58:58 server1 kernel: Installing knfsd (copyright (C) 1996 okir@monad.swb.de).

Sep 13 10:59:08 server1 exportfs[3232]: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "desktop1:/home".   Assuming default behaviour ('no_subtree_check').   NOTE: this default has changed since nfs-utils version 1.0.x

Sep 13 10:59:08 server1 exportfs[3232]: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export "server2:/home".   Assuming default behaviour ('no_subtree_check').   NOTE: this default has changed since nfs-utils version 1.0.x

Sep 13 10:59:08 server1 exportfs[3232]: /etc/exports [3]: Neither 'subtree_check' or 'no_subtree_check' specified for export "matsx60s:/home".   Assuming default behaviour ('no_subtree_check').   NOTE: this default has changed since nfs-utils version 1.0.x
```

Don't know if the above could be a problem.

If I now on my client try to mount the disk:

```
# mount /home/mats/server1/

mount: server1:/home/mats/ failed, reason given by server: Permission denied
```

So, I restart portmap on the server:

```
# /etc/init.d/portmap restart

 * Saving portmap table ...                                                                                                             [ ok ]

 * Stopping NFS mountd ...                                                                                                              [ ok ]

 * Stopping NFS daemon ...                                                                                                              [ ok ]

 * Unexporting NFS directories ...                                                                                                      [ ok ]

 * Stopping NFS statd ...                                                                                                               [ ok ]

 * Stopping portmap ...                                                                                                                 [ ok ]

 * Starting portmap ...                                                                                                                 [ ok ]

 * Reloading portmap table ...                                                                                                          [ ok ]

 * Starting NFS statd ...                                                                                                               [ ok ]

 * Exporting NFS directories ...

exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "desktop1:/home".

  Assuming default behaviour ('no_subtree_check').

  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export "server2:/home".

  Assuming default behaviour ('no_subtree_check').

  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [3]: Neither 'subtree_check' or 'no_subtree_check' specified for export "matsx60s:/home".

  Assuming default behaviour ('no_subtree_check').

  NOTE: this default has changed since nfs-utils version 1.0.x                                                                          [ ok ]

 * Starting NFS mountd ...                                                                                                              [ ok ]

 * Starting NFS daemon ...                                                                                                              [ ok ]

 * Starting NFS smnotify ...                                                                                                            [ ok ]
```

And then try mounting on the client:

```
# mount /home/mats/server1/
```

it runs just fine...

----------

## Hu

rc-update show only prints out configuration information, so it will stay the same across reboots.  The broken runlevel warning seems to be that you have a runlevel entry for a service that is not present.  It may be a problem, but it does not contribute to your NFS problem.

There is no need to cat /var/log/syslog.  You can tell grep to read the file directly: grep nfs /var/log/syslog.

The warnings from exportfs indicate that you have not told the system how to handle subtree checking.  You can make the warning go away by explicitly marking whether subtree checking should be enabled for each mount.

When the client is rejected by the server, run showmount -e server and post the results.  Your output is consistent with the server believing that the requested filesystem should not be exported.

----------

## m_gustafsson

When the client is rejected I did run (on the client):

```
# showmount -e server1

Export list for server1:

/home matsx60s,server2,desktop1
```

After restarting portmap on the server I again ran showmount on the client:

```
# showmount -e server1

Export list for server1:

/home matsx60s,server2,desktop1
```

And now I can do the mounting:

```
# mount server1:/home/mats server1
```

My client is called server2.

----------

## jamapii

You aren't just restarting portmapper, you are restarting all of NFS utils. If you just do 

/etc/init.d/portmap pause; /etc/init.d/portmap start

does it still go from nonworking to working state?

I think NFS has trouble with multiple lines in exportfs, exporting the same directory or subdirs of each other. Try a single line

```

/home -async,rw desktop1 server2(all_squash,anonuid=1000,anongid=1000) matsx60s(all_squash,anonuid=1000,anongid=1000)

```

(this goes on a single line)

----------

## m_gustafsson

Jamapii you are right, if I just restart portmap it does not solve the problem (server1 being server and server2 being client):

```
server2 # mount /home/mats/server1/

mount: server1:/home/mats/ failed, reason given by server: Permission denied
```

```
server1 # /etc/init.d/portmap pause

 * Stopping portmap ...                                                   [ ok ]

server1 # /etc/init.d/portmap start

 * Starting portmap ...                                                   [ ok ]
```

```
server2 mats # mount /home/mats/server1/

mount: server1:/home/mats/ failed, reason given by server: Permission denied
```

I tried to change my /etc/exports as you suggested, but I still see the same behaviour:

```
server2 # mount /home/mats/server1/

mount: server1:/home/mats/ failed, reason given by server: Permission denied
```

```
server1 # cat /etc/exports

# /etc/exports: NFS file systems being exported.  See exports(5).

/home -async,rw desktop1 server2(all_squash,anonuid=1000,anongid=1000) matsx60s(all_squash,anonuid=1000,anongid=1000)
```

If I check my syslog after trying to do a mount I see:

```
server1 # cat /var/log/syslog | grep server2

Sep 16 08:01:25 server1 mountd[3239]: authenticated mount request from server2:850 for /home/mats (/home)
```

In messages I see:

```
server1 # cat /var/log/messages | grep nfs

Sep 16 07:52:29 server1 kernel: nfsd: last server has exited

Sep 16 07:52:29 server1 kernel: nfsd: unexporting all filesystems
```

If I then restart portmap:

```
server1 # /etc/init.d/portmap restart
```

And look into messages:

```
Sep 16 07:52:29 server1 kernel: nfsd: last server has exited

Sep 16 07:52:29 server1 kernel: nfsd: unexporting all filesystems

Sep 16 08:49:25 server1 kernel: Installing knfsd (copyright (C) 1996 okir@monad.swb.de).

Sep 16 08:05:15 server1 kernel: nfsd: last server has exited

Sep 16 08:05:15 server1 kernel: nfsd: unexporting all filesystems
```

Now I can mount the disk again on server2:

```
server2 mats # mount /home/mats/server1/
```

Shouldn't there be any messages in /var/messages about nfsd exporting all filesystem, or is that not reported?

Thanks for you kind help   :Smile: 

----------

## jamapii

If the single line in exports doesn't work, I can't think of any solution, only workarounds. My workaround would be to put the restart command in /etc/conf.d/local.start (and do "rc-update add local default").

The command can be simpler/more targeted, I think a "/etc/init.d/nfs restart" or even "/etc/init.d/nfs reload" would have the same effect.

You can also try raw IP addresses instead of DNS names, to see if it makes a difference.

----------

## m_gustafsson

I tried to replace server2 with its IP address in /etc/exports, but that did not help.

Then tried /etc/init.d/nfs reload which seems to be enough for getting mounting working.

So, I added /etc/init.d/nfs into /etc/conf.d/local.start as suggested and then did a reboot.

And, now it works. So the workaround seems to be ok   :Very Happy: 

But, still I am a bit curious to what my problem is...

When I run nfs reload I get the following warning:

```
server1 mats # /etc/init.d/nfs reload

 * Reloading /etc/exports ...

exportfs: Warning: /home does not support NFS export.

exportfs: Warning: /home does not support NFS export
```

Could this waring be involved in my problem?

Maybe I should just forget about this and use the workaround   :Smile: 

----------

## madchaz

Is it possible the problem is you are not starting the services in the right order?

When you boot, what starts first, nfs or portmap?

Try removing portmap

```
rc-update del portmap default
```

As you already have NFS, it should be forced to start as it is a requirement for NFS to start. (it should do this automatically)

----------

## m_gustafsson

madchaz, I did a reboot and it looks like portmap is started just before NFS.

I then tried to remove portmap:

```
# rc-update del portmap
```

and did a reboot...

```
# rc-update show

 * Broken runlevel entry: /etc/runlevels/default/xinetd

             apache2 |      default                  

             apcupsd |      default                  

            bootmisc | boot                          

             checkfs | boot                          

           checkroot | boot                          

               clock | boot                          

         consolefont | boot                          

            ddclient |      default                  

            hostname | boot                          

             keymaps | boot                          

               local |      default nonetwork        

          localmount | boot                          

             modules | boot                          

               mysql |      default                  

            net.eth0 |      default                  

              net.lo | boot                          

            netmount |      default                  

                 nfs |      default                  

                ntpd |      default                  

           rmnologin | boot                          

               samba |      default                  

       squeezecenter |      default                  

                sshd |      default                  

            svnserve |      default                  

              svscan |      default                  

            sysklogd |      default                  

             uptimed |      default                  

             urandom | boot                          

          vixie-cron |      default
```

It anyway looks like portmap is started before NFS though, at least that is what I can see when watching the startup sequence presented on the screen while the computer is booting.

And the problem with mounting remains.

----------

