5

I've set my Raspberry Pi up as an NFS server, but I cannot connect to it with NFS version 4. However, version 3 works. From my Kubuntu 13.04 client:

$ sudo mount -t nfs -o proto=tcp,port=2049,vers=4 192.168.1.91:/export /mnt/pi -v
mount.nfs: timeout set for Tue Sep 17 09:47:26 2013
mount.nfs: trying text-based options 'proto=tcp,port=2049,vers=4,addr=192.168.1.91,clientaddr=192.168.1.7'
mount.nfs: mount(2): Permission denied
mount.nfs: access denied by server while mounting 192.168.1.91:/export
$ sudo mount -t nfs -o proto=tcp,port=2049,vers=3 192.168.1.91:/export /mnt/pi -v
mount.nfs: timeout set for Tue Sep 17 09:47:31 2013
mount.nfs: trying text-based options 'proto=tcp,port=2049,vers=3,addr=192.168.1.91'
mount.nfs: prog 100005, trying vers=3, prot=6
mount.nfs: trying 192.168.1.91 prog 100005 vers 3 prot TCP port 35976

From the server, it seems that NFS version 4 is compiled in the kernel.

$ rpcinfo -p
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  51953  status
    100024    1   tcp  42383  status
    100003    2   tcp   2049  nfs
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    2   tcp   2049
    100227    3   tcp   2049
    100003    2   udp   2049  nfs
    100003    3   udp   2049  nfs
    100003    4   udp   2049  nfs
    100227    2   udp   2049
    100227    3   udp   2049
    100021    1   udp  41873  nlockmgr
    100021    3   udp  41873  nlockmgr
    100021    4   udp  41873  nlockmgr
    100021    1   tcp  35095  nlockmgr
    100021    3   tcp  35095  nlockmgr
    100021    4   tcp  35095  nlockmgr
    100005    1   udp  60943  mountd
    100005    1   tcp  44936  mountd
    100005    2   udp  52342  mountd
    100005    2   tcp  56312  mountd
    100005    3   udp  57888  mountd
    100005    3   tcp  35976  mountd

==EDIT==

Server logs at /var/log/messages are unchanged for both attempts. Server logs at /var/log/syslog are unchanged for unsuccessful v4 attempts, but are appended for successful v3 attempts, as follows.

Sep 17 21:48:27 raspberrypi rpc.mountd[24098]: authenticated mount request from 192.168.1.7:1021 for /export (/export)
Sep 17 22:09:12 raspberrypi rpc.mountd[24098]: authenticated mount request from 192.168.1.7:790 for /export (/export)
Sep 17 22:09:51 raspberrypi rpc.mountd[24098]: authenticated mount request from 192.168.1.7:1002 for /export (/export)

Oddly enough, it seems like the port is changing, despite me specifying 2049?

==EDIT== Contents of server's /etc/export

/export       192.168.1.0/24(rw,fsid=0,insecure,no_subtree_check,async,crossmnt)
Sparhawk
  • 683
  • 4
  • 18
  • 34

2 Answers2

4

NFS uses IP/Hostname based security so that means you should give permission on NFS server to clients. Permissions should be defined at /etc/exports file. Example /etc/exports file:

# Path          Client IP (options)
/BACKUP/DATA    192.168.1.4(rw,no_root_squash,sync,crossmnt,fsid=1)
/BACKUP/MOVIES  192.168.1.6(rw,no_root_squash,sync,crossmnt,fsid=1)

After editing /etc/exports file you should run 'exportfs -ra' command to re-read exports file by NFS server daemon. Then try to mount;

on client 192.168.21.4;

mount -t nfs -o vers=3 192.168.1.91:/BACKUP/DATA /mnt/pi/DATA -v

on client 192.168.1.6

mount -t nfs -o vers=3 192.168.1.91:/BACKUP/DATA /mnt/pi/MOVIES -v

You should watch your log files and try to understand what happening via tail command like below.

tail -f /var/log/syslog
tail -f /var/log/messages

Log outputs should give clue.

Update:

Since you're saying that it works with NFSv3 not NFSv4, you should do extra things to use NFSv4.

Create a directory to share in /export folder.

mkdir -p /export/myfolder

then bindmount it. (add line below into /etc/fstab file at server)

/foo/myfolder  /exports/myfolder  none    bind

and put this line into /etc/exports file

/exports/myfolder 192.168.1.0/24(rw,sync,insecure,no_subtree_check,nohide)

run 'exportfs -ra' and check your exports with 'exportfs -rv' command.

then try to mount it :

mount -t nfs4 192.168.1.91:/myfolder  /myfolder -o rw

You can add this line into /etc/fstab file at client machine to mount it every boot.

192.168.1.91:/myfolder  /myfolder  nfs4   rw,auto,hard,intr
gurcanozturk
  • 3,748
  • 1
  • 21
  • 17
2
/exports/myfolder 192.168.1.0/24(rw,sync,insecure,no_subtree_check,nohide)

run exportfs -ra and check your exports with 'exportfs -rv' command.

then try to mount it :

mount -t nfs4 192.168.1.91:/myfolder  /myfolder -o rw

You can add this line into /etc/fstab file at client machine to mount it every boot.

Cant you just use the /etc/fastab- To enter the key user as machine Mount * ( Every Reboot) - < Turn on > - to access the power , of the IP _ S -

MatsK
  • 2,882
  • 3
  • 17
  • 22
Alpha
  • 21
  • 1