1

I have two NFS exports on my server configured identically in /etc/exports. On my NFS client one always auto-mounts with NFS-3 while the other mounts with NFS-4. I want nfs-4. How do I make that happen?

On the server ('nina'):

# cat /etc/exports
/home 192.168.0.0/24(rw,no_all_squash,anonuid=1545,anongid=501)
/misc/fedora-backup 192.168.0.0/24(rw,no_all_squash,anonuid=1545,anongid=501)
# exportfs -arv
exporting 192.168.0.0/24:/misc/fedora-backup
exporting 192.168.0.0/24:/home

On the client:

$ ls /net/nina/home /net/nina/misc/fedora-backup
/net/nina/home:
bhepple  data  guest  lost+found  nina  watched-files

/net/nina/misc/fedora-backup:
backup-copy  lost+found  media
$ mount |grep nfs
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
nina:/home on /net/nina/home type nfs4 (rw,nosuid,nodev,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.0.104,local_lock=none,addr=192.168.0.19)
nina:/misc/fedora-backup on /net/nina/misc/fedora-backup type nfs (rw,nosuid,nodev,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.19,mountvers=3,mountport=20048,mountproto=udp,local_lock=none,addr=192.168.0.19)

These are both up to date fedora-37 systems.

EDIT a manual mount also shows the error:

sudo mount -t nfs4 nina:/misc/fedora-backup ~/tmp/mnt
mount.nfs4: mounting nina:/misc/fedora-backup failed, reason given by server: No such file or directory 

If I omit the -t nfs4 it mounts OK, but it is only nfs-3.

4
  • @ArtemS.Tashkinov I'm using autofs - if I put -fstype=nfs4 in /etc/auto.net on the client, it just refuses to mount at all. If I try a 'manual' mount it gives an error: $ mount -t nfs4 nina:/misc/fedora-home ~/tmp/mnt mount.nfs4: failed to apply fstab options I get the same error without the '-t nfs4'
    – wef
    Jan 30, 2023 at 23:02
  • @ArtemS.Tashkinov - oh wait. I should have used sudo. With the manual mount I get mount.nfs4: mounting nina:/misc/fedora-home failed, reason given by server: No such file or directory. Without the -t nfs4 I get a good mount (but nfs3)
    – wef
    Jan 30, 2023 at 23:08
  • So what is the directory name: /misc/fedora-home, /misc/fedora-backup or /home?
    – White Owl
    Jan 30, 2023 at 23:38
  • @white - oh, I muddled that. There are actually both fedora-home and fedora-backup. I wanted to simplify. Both fedora-* have the same nfs-3 problem.
    – wef
    Jan 30, 2023 at 23:51

3 Answers 3

1

It looks like nfs4 can't export separate directories - they all need to be nested together, possibly using bind mount to point where you want.

https://superuser.com/questions/362736/cant-mount-nfs4-share

0

Look for the option vers on the client side. You have vers=4.2 on the home mount and vers=3 on backup.

Also, type nfs4 and type nfs can be used to determine version if the vers or its alias nfsvers are not specified.

3
  • yes, I know that, sorry if I was not clear. The question is why am I getting nfs-3 on some mounts but nfs-4 on others, and how can make them all nfs-4
    – wef
    Jan 30, 2023 at 23:14
  • @wef How do you mount? Add to the post the /etc/fstab or /etc/auto.net, or whatever else you use to the actual mounting.
    – White Owl
    Jan 30, 2023 at 23:25
  • I normally use autofs but for testing/debugging I'm using sudo mount -t nfs4 nina:/misc/fedora-home ~/tmp/mnt and I get the error: mount.nfs4: mounting nina:/misc/fedora-home failed, reason given by server: No such file or directory Without the -t nfs4 it works OK, but is nfs-3.
    – wef
    Jan 30, 2023 at 23:27
0

I'm using Debian but got the same issue, in particular with using the next stable release "Trixie" (now Debian13/testing) as client together with a current stable "Bookworm" (Debian12/stable) server. I think to understand the problem will also help for fedora.

My installation uses Kerberos. Default used NFS protocol is version 4.2. The NFS client on Debian12 falls back to protocol version 3 automatically if it cannot establish a connection with version 4. This can be tested with mount. Please note the command prompt server12:~$ , client12:~$ , or client13:~$ .

These exports does not conform to NFS4 to have an exported root directory with only nested directories exported. But it can be mounted with NFS3.

server12:~$ cat /etc/exports
/home      192.168.24.0/24(sec=krb5p,rw,async,no_subtree_check)
/srv/nfs   192.168.24.0/24(sec=krb5p,rw,async,no_subtree_check,fsid=0,crossmnt)

server12:~$ sudo exportfs -rv
exporting 192.168.24.0/24:/home
exporting 192.168.24.0/24:/srv/nfs

client12:~$ sudo showmount --exports server
Export list for server:
/home    192.168.24.0/24
/srv/nfs 192.168.24.0/24

client12:~$ sudo mount -vvv -t nfs4 -o sec=krb5p server:/srv/nfs /mnt/server
mount.nfs4: timeout set for Mon Jan  1 14:38:33 2024
mount.nfs4: trying text-based options 'sec=krb5p,vers=4.2,addr=192.168.24.125,clientaddr=192.168.24.65'
mount.nfs4: mount(2): No such file or directory
mount.nfs4: trying text-based options 'sec=krb5p,addr=192.168.24.125'
mount.nfs4: prog 100003, trying vers=3, prot=6
mount.nfs4: trying 192.168.24.125 prog 100003 vers 3 prot TCP port 2049
mount.nfs4: prog 100005, trying vers=3, prot=17
mount.nfs4: trying 192.168.24.125 prog 100005 vers 3 prot UDP port 51678

The mount shows that the connection attempts to start with default vers=4.2 and falls back to vers 3 with success. You can see that it is connected with vers=3:

client12:~$ findmnt /mnt/server
/mnt/server server:/srv/nfs nfs    rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp, ...

But on Debian13 the NFS client does not fall back to NFS3 anymore. This caused me problems when upgrading to "Trixie". You have to specify now what NFS version to use:

client13:~$ sudo mount -vvv -t nfs4 -o sec=krb5p server:/srv/nfs /mnt/server
mount.nfs4: timeout set for Mon Jan  1 16:21:13 2024
mount.nfs4: trying text-based options 'sec=krb5p,vers=4.2,addr=192.168.24.125,clientaddr=192.168.24.83'
mount.nfs4: mount(2): No such file or directory
mount.nfs4: mounting server:/srv/nfs failed, reason given by server: No such file or directory

client13:~$ # But specifying vers=3 as additional option then it connects:
client13:~$ sudo mount -vvv -t nfs4 -o sec=krb5p,vers=3 server:/srv/nfs /mnt/server
mount.nfs4: timeout set for Mon Jan  1 16:29:31 2024
mount.nfs4: trying text-based options 'sec=krb5p,vers=3,addr=192.168.24.125'
mount.nfs4: prog 100003, trying vers=3, prot=6
mount.nfs4: trying 192.168.24.125 prog 100003 vers 3 prot TCP port 2049
mount.nfs4: prog 100005, trying vers=3, prot=17
mount.nfs4: trying 192.168.24.125 prog 100005 vers 3 prot UDP port 51678

Assuming a successful configured NFS server, here are my exports and mounts for a valid NFS4 configuration for completeness.

server12:~$ cat /etc/exports
# Only for testing fallback to NFS3
#/home          192.168.24.0/24(sec=krb5p,rw,async,no_subtree_check)
#/srv/nfs       192.168.24.0/24(sec=krb5p,rw,async,no_subtree_check,fsid=0,crossmnt)
#
# Valid NFS4 configuration
/srv/nfs        gss/krb5p(rw,async,no_subtree_check,fsid=0,crossmnt)
/srv/nfs/home   gss/krb5p(rw,async,no_subtree_check)

server12:~$ cat /etc/fstab
PARTLABEL=rootfs   /       ext4   errors=remount-ro   0   1
PARTLABEL=swap     none    swap   sw                  0   0
/dev/vdb           /media  ext4   errors=remount-ro   0   1

/media          /srv/nfs/media           none   bind  0   0
/home/ingo      /srv/nfs/home/ingo       none   bind  0   0
/home/mary      /srv/nfs/home/mary       none   bind  0   0
/home/common    /srv/nfs/home/common     none   bind  0   0


client13:~$ cat /etc/fstab
# Your local mounts ..., then for NFS4 mounts
server:/       /mnt/srv    nfs4    sec=krb5p   0   0
server:/home   /mnt/home   nfs4    sec=krb5p   0   0

client13:~$ ls /mnt/srv
home/  media/
client13:~$ ls /mnt/home
common/  ingo/  mary/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .