# [SOLVED]nfs mounts ok, but no files are shown and permission

## potuz

Hi, I'm new to nfs and in need of help cause I cant get my folder to be shared. Running without a firewall

The server has

```
root@whiskey ~ #cat /etc/exports

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

/srv/nfs      192.168.1.0/24(rw,fsid=root,no_subtree_check)

/srv/nfs/pictures   191.168.1.0/24(rw,nohide,no_subtree_check)

```

The pictures folder is a mount --bind to another folder on disk with the following permissions:

```

#ls -al /srv/nfs/

total 12

drwxr-xr-x  3 root root  4096 Jul  2 06:50 .

drwxr-xr-x  3 root root  4096 Jul  2 06:50 ..

drwxrwx--- 21 root photo 4096 Jan 24  2015 pictures

```

And the exports are shown fine here:

```

#exportfs -v

/srv/nfs         192.168.1.0/24(rw,wdelay,root_squash,no_subtree_check,fsid=0,sec=sys,rw,secure,root_squash,no_all_squash)

/srv/nfs/pictures

      191.168.1.0/24(rw,wdelay,nohide,root_squash,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)

```

Now on the client side I run

```

rye ~ # mount whiskey:/pictures /media/pictures/

rye ~ # mount  | grep pictures

whiskey:/pictures on /media/pictures type nfs4 (rw,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.143,local_lock=none,addr=192.168.1.19)

```

So that the mount seems fine. I can check the connection on the server with

```

#netstat -tn | grep 2049

tcp        0      0 192.168.1.19:2049       192.168.1.143:730       ESTABLISHED

```

However ls /media/pictures does not show any files. And attempting to write to disk gives a permission error. Also the directory itself does not have the same permissions shown above:

```

rye ~ # echo "hola" > /media/pictures/hola.txt

-bash: /media/pictures/hola.txt: Permission denied

# ls -al /media/

total 12

drwxr-xr-x  3 root root  4096 Jul  2 07:23 .

drwxr-xr-x 22 root root  4096 Jun 28 21:28 ..

-rw-r--r--  1 root root     0 Mar 28 10:26 .keep

drwxr-xr-x  2 root photo 4096 Jul  2 06:50 pictures

```

(Same if I try with my user in the "photo"  group instead of root). 

Finally and probably unrelated, if I try to mount with version 3 instead of 4:

```

rye ~ # showmount -e whiskey 

Export list for whiskey:

/srv/nfs/pictures 191.168.1.0/24

/srv/nfs          192.168.1.0/24

rye ~ # mount -t nfs -o vers=3 whiskey:/srv/nfs/pictures /media/pictures -v

mount.nfs: timeout set for Sun Jul  2 10:55:34 2017

mount.nfs: trying text-based options 'vers=3,addr=192.168.1.19'

mount.nfs: prog 100003, trying vers=3, prot=6

mount.nfs: trying 192.168.1.19 prog 100003 vers 3 prot TCP port 2049

mount.nfs: prog 100005, trying vers=3, prot=17

mount.nfs: trying 192.168.1.19 prog 100005 vers 3 prot UDP port 55246

mount.nfs: mount(2): Permission denied

mount.nfs: access denied by server while mounting whiskey:/srv/nfs/pictures

```

And in the server logs:

```
Jul  2 10:55:17 whiskey rpc.mountd[19896]: authenticated mount request from 192.168.1.143:784 for /srv/nfs/pictures (/srv/nfs)

Jul  2 10:55:17 whiskey rpc.mountd[19896]: request to export directory /srv/nfs/pictures below nearest filesystem /srv/nfs

```

Any help will be appreciated.Last edited by potuz on Sun Jul 02, 2017 5:01 pm; edited 1 time in total

----------

## potuz

EDIT: Disregard this post, this is simply explained by the original permissions of the directory /srv/nfs/pictures (before the mount --bind option). 

Adding a little more info that is really confusing to me: I changed ownership of the export in the server to 

```
root@whiskey ~ #ls -alh /srv/nfs/

total 12K

drwxr-xr-x  3 root    root    4.0K Jul  2 06:50 .

drwxr-xr-x  3 root    root    4.0K Jul  2 06:50 ..

drwxrwx--- 21 potuz potuz 4.0K Jan 24  2015 pictures

```

Where the user potuz has

```

#id potuz

uid=1000(potuz) gid=1000(potuz) groups=1000(potuz),10(wheel),1004(photo)

```

And in the client I have

```

$ id

uid=1000(potuz) gid=1000(potuz) groups=1000(potuz),7(lp),10(wheel),16(cron),27(video),85(usb),104(wireshark),250(portage),1004(photo)

```

But still this happens before and after mounting!

```

$ ls -alh /media/

total 12K

drwxr-xr-x  3 root    root    4.0K Jul  2 12:24 .

drwxr-xr-x 22 root    root    4.0K Jun 28 21:28 ..

-rw-r--r--  1 root    root       0 Mar 28 10:26 .keep

drwxr-x---  2 potuz potuz 4.0K Jul  2 12:24 pictures

$ mount /media/

$ ls -alh /media/

total 12K

drwxr-xr-x  3 root root  4.0K Jul  2 12:24 .

drwxr-xr-x 22 root root  4.0K Jun 28 21:28 ..

-rw-r--r--  1 root root     0 Mar 28 10:26 .keep

drwxr-xr-x  2 root photo 4.0K Jul  2 06:50 pictures

```

Which where the previous owners, this is persistent after reboots, so there's somewhere that nsf is saving status.

----------

## potuz

Solved the problem,  I failed to add crossmnt to the list of flags.

----------

