NFS4 mounting problems

Asked by ealthuis

Over the last few weeks many questions were asked, and many answers recieved.

This document describes the current situation using 678067 as a guide.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
ealthuis
Solved:
Last query:
Last reply:
Revision history for this message
ealthuis (ealthuis) said :
#1

It all starts with /etc/exports on the server:

 /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 192.168.0.1/24(rw,sync,fsid=0,crossmnt,no_subtree_check)
#/srv/nfs4/home 192.168.0.1/24(rw,sync,no_subtree_check)
# exporting to a local network
/export 192.168.0.0/24(rw,fsid=0,insecure,no_subtree_check,async)
/export/mass 192.168.0.0/24(rw,fsid=0,insecure,no_subtree_check,async)
/export/mass0 192.168.0.0/24(rw,fsid=0,insecure,no_subtree_check,async)
/export/mass1 192.168.0.0/24(rw,fsid=0,insecure,no_subtree_check,async)
/export/mass2 192.168.0.0/24(rw,fsid=0,insecure,no_subtree_check,async)

Instructions are to have the first not commented line and the following one in this file.
If I do that the exported file is only the first of the four I want, but worse, (/export/mass) it only stays on the client for about 60 seconds.

When I comment out the four lines /export/mass? etc then not only is mass (the first in the list) exported to the client but it stays.
 This is so on all clients.

Thus the question is "how to train nfs4 to export all four files and the clients to not remove the files after about 60 seconds
At a minimum I need two partitions (files) mass and mass2, the last one is used for backups for all four computers.

Revision history for this message
ealthuis (ealthuis) said :
#2

Correction, the exported partition does not stay, it goes away in about 60 seconds always

Revision history for this message
Manfred Hampl (m-hampl) said :
#3

Is there a specific reason to have redundant directories exported?
If a client is able to nfs-mount /export then the client can access all its subdirectories (/export/mass, /exports/mass0, etc.) without additional nfs-mount. This would make sense only if you have different access rights, but I cannot see any differentiation.

I suggest that you try the simplest possible variant.
nfs-export only the directory /export on the server and try nfs-mounting it on one client.
Does this work? If not, are there any error messages on the server and/or the client?

What are now the contents of /etc/hosts.allow on the server (see https://answers.launchpad.net/ubuntu/+question/678067 )?

Revision history for this message
ealthuis (ealthuis) said :
#4

Yes, the command to mount mass succeeds on all three clients until just now

ea@discovery:~$ cat /etc/hosts.allow
# /etc/hosts.allow: list of hosts that are allowed to access the system.
# See the manual pages hosts_access(5) and hosts_options(5).
#
# Example: ALL: LOCAL @some_netgroup
# ALL: .foobar.edu EXCEPT terminalserver.foobar.edu
#
# If you're going to protect the portmapper use the name "rpcbind" for the
# daemon name. See rpcbind(8) and rpc.mountd(8) for further information.
# next line added for NFS usage
#rcpbind mountd nfsd statd lockd rquotad :
# ALL: 127.0.0.1 192.168.0.10/4
local @nfs4domain.netapp.com

ea@discovery:~$

Revision history for this message
ealthuis (ealthuis) said :
#5

The above was written on the server,
this happened on the client:

ea@seanix:~$ sudo mount -v -t nfs -o proto=tcp,port=2049 192.168.0.12:/ /media/mass
mount.nfs: timeout set for Mon Jan 28 05:32:01 2019
mount.nfs: trying text-based options 'proto=tcp,port=2049,vers=4.2,addr=192.168.0.12,clientaddr=192.168.0.11'
mount.nfs: mount(2): Connection refused
mount.nfs: trying text-based options 'proto=tcp,port=2049,addr=192.168.0.12'
mount.nfs: prog 100005, trying vers=3, prot=6
mount.nfs: portmap query failed: RPC: Program not registered
mount.nfs: requested NFS version or transport protocol is not supported
ea@seanix:~$

I again entered the iptables rules for input from this client and output from the server

The same happened on another client where yesterday it also worked.

Revision history for this message
ealthuis (ealthuis) said :
#6

Weird, I was using the cinnamon desktop which BTW windows users will like, when I tried the earlier mounts. I restarted the computer and used the ubuntu desktop and I reinstalled the iptables rules for both clients and the server and the mounts worked. However when I tried to mount mass2 all I got were the mass files and directories. And they stayed around for about 60 seconds.

I have not found in all the documentation I have researched a way of telling NFS4 to keep the mounts active until shut down by the user.

In the 50 seconds that I have the mount open on the client I have full read and write access to all files. (I timed it)

Revision history for this message
Manfred Hampl (m-hampl) said :
#7

I refuse to try giving further support, because you seem to be ignoring all my recommendations.
- the hosts.allow file does not contain any meaningful line
- instead of a single "/export" directory you still are trying with different (sub-)directories.

Did you recently change the /etc/hosts.allow (and /etc/hosts.deny) file on the server?

Revision history for this message
ealthuis (ealthuis) said :
#8

I do not blame you for feeling unhappy about this whole mess, I feel the same way, even more so since NFS worked for me for more than five years and now with a new version we are in this ...

The line about domain was recommended in one of the many articles I read, and is in all four hosts.allow files. I'll happily change that if you feel it should be different.
I have on the server not changed the hosts.deny at all, it has been ALL:PARANOID from thr beginning.

I am using just one directory and it works, but does not stay.

Revision history for this message
ealthuis (ealthuis) said :
#9

Finally I am left with three problems:

Iptables rules disappear when the server is shut down requiring entering them again

The exported partition only remains active on the client for about 50 seconds

I cannot mount any other partitions from /export, they all have the data from the first partition

Revision history for this message
ealthuis (ealthuis) said :
#10

The iptables problems have been solved by using sudio /sbin/iptables-save

The exported partition only stayed for a few seconds: A script which mounted in NFSv3 all partitions apparently denied the new export any time. Stopped the script , the exported partition stays.

The third problem remains.

Revision history for this message
Manfred Hampl (m-hampl) said :
#11

Repeating my question from comment #3:

Is there a specific reason to have redundant directories exported?
If a client is able to nfs-mount /export then the client can access all its subdirectories (/export/mass, /exports/mass0, etc.) without additional nfs-mount. This would make sense only if you have different access rights, but I cannot see any differentiation.

Revision history for this message
ealthuis (ealthuis) said :
#12

Originally it was nice to have all four mounted. However I "need " mass because all the files (spreadsheets etc) are there and I need to access them from at least one other client. So only mass and mass2 are needed, mass2 because the two desktop clients use mass2 for their backups weekly.

Now as to the second part I understand that all sub directories are available but I only see mass no matter how I change the command:

sudo mount -t nfs -0 proto=tcp,port=2049 192.168.0.12:/ /media/mass

sudo mount -t nfs -0 proto=tcp,port=2049 192.168.0.12:/ /

sudo mount -t nfs -0 proto=tcp,port=2049 192.168.0.12:/
This last one responds: mount: 192.168.0.12:/: can't find in /etc/fstab.

So either of the other two only give me mass

I need to reiterate, I can on all three clients access mass when ever I want as long as the server is up, that includes the laptop upstairs.

Revision history for this message
ealthuis (ealthuis) said :
#13

If a client is able to nfs-mount /export then the client can access all its subdirectories:

my /etc/exports file will only export mass, no matter how I comment out different lines as in this:

ea@discovery:~$ cat /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 192.168.0.1/24(rw,sync,fsid=0,crossmnt,no_subtree_check)
#/srv/nfs4/home 192.168.0.1/24(rw,sync,no_subtree_check)
# exporting to a local network
# /export 192.168.0.0/24(rw,fsid=0,insecure,no_subtree_check,async)
/export/mass 192.168.0.0/24(rw,fsid=0,insecure,no_subtree_check,async)
# /export/mass0 192.168.0.0/24(rw,fsid=0,insecure,no_subtree_check,async)
# /export/mass1 192.168.0.0/24(rw,fsid=0,insecure,no_subtree_check,async)
# /export/mass2 192.168.0.0/24(rw,fsid=0,insecure,no_subtree_check,async)

ea@discovery:~$
If I uncomment /export I get nothing,
If I also comment /export/mass I get nothing
If I uncomment the other three I get nothing and I never get any of the other three.

This is all comments on the situation, I am content with what I can export I feel that there may be a problem either with my setup on the server or with nfsv4.
The four partitions are mounted in fstab both on /media and /export

Revision history for this message
Manfred Hampl (m-hampl) said :
#14

Don't confuse the directory /export/mass and the mount point /media/mass on the client!

What I suggest is the following:

Export only the the directory /export on the server (all lines commented out except /export)
Remember to restart the nfs server after a change in /etc/exports !

Then create an empty directory as mount point on a client with a suitable name, maybe something like /media/my_nfs

And finally mount the nfs-exported server share

sudo mount -t nfs -0 proto=tcp,port=2049 192.168.0.12:/export /media/my_nfs

If this is successful, you should have the following directories om the client:
/media/my_nfs
/media/my_nfs/mass
/media/my_nfs/mass0
/media/my_nfs/mass1
/media/my_nfs/mass2

Revision history for this message
ealthuis (ealthuis) said :
#15

I did to the letter as you suggested, and I have /media/my_nfs and within that all four directories however mass etc. are empty.

All of the above directories are owned ea:ea, and have free space 24.9 GB

I checked permissions on the server right down to /media and all are ea:ea

Revision history for this message
Manfred Hampl (m-hampl) said :
#16

What is the output of
ls -l /export
on the server?

What is the output of the commands
mount | grep media
ls -l /media /media/my_nfs
on the client?

Revision history for this message
ealthuis (ealthuis) said :
#17

On the server:
ea@discovery:~$ ls -l /export
total 48
drwxrwxrwx 66 ea ea 36864 Feb 1 09:03 mass
drwxrwxrwx 6 ea ea 4096 Dec 24 10:01 mass0
drwxrwxrwx 3 ea ea 4096 Sep 1 08:09 mass1
drwxrwxrwx 13 ea ea 4096 Jan 27 08:16 mass2
ea@discovery:~$
on the client:
mount | grep media

Revision history for this message
ealthuis (ealthuis) said :
#18

Mount | grep media had no output

ea@seanix:~$ ls -l /media/media/my_nfs
ls: cannot access '/media/media/my_nfs': No such file or directory
ea@seanix:~$
 So I did this to show what is in /media:

ea@seanix:~$ ls -l /media/
total 24
drwxr-x---+ 2 root root 4096 Feb 1 06:26 ea
drwxr-xr-x 2 root root 4096 Jan 26 08:00 mass
drwxr-xr-x 2 root root 4096 Jan 26 08:00 mass0
drwxr-xr-x 2 root root 4096 Jan 26 08:00 mass1
drwxr-xr-x 2 root root 4096 Jan 26 08:00 mass2
drwxr-xr-x 2 ea ea 4096 Feb 3 09:43 my_nfs
ea@seanix:~$

ea@seanix:~$ ls -l /media/my_nfs
total 452
-rw-rw-r-- 1 ea ea 460934 Jan 28 2017 statement.pdf
ea@seanix:~$

the four partitions that showed in /media/my_nfs go away when the system is shut down
the statement.pdf is a file I copied into my_nfs

Revision history for this message
ealthuis (ealthuis) said :
#19

The problem has been fixed, all4 partitions now mount correctly.