# mount_nfs



## Halfe (Apr 3, 2014)

Hi.

I'm trying to use mount_nfs(8) to another server that is on another end of a VPN line. This is for database purpose only not file distribution.  But when I use `mount_nfs //(server ip):/(share path)/ /mnt/(destination folder/` I get a permission denied.

I have used `sudo -s` so I have root access. I've mounted nullfs between users and that works great but that's internally. but externally it won't work. What am I missing.

Can anyone help me?

Halfe


----------



## SirDice (Apr 3, 2014)

By default only @root can mount filesystems. It doesn't matter if it's NFS, nullfs or anything else. It's the act of mounting that requires root access.


----------



## Halfe (Apr 3, 2014)

So what do I do wrong. 

How can I type in login credentials of the other server so I can connect.


----------



## SirDice (Apr 3, 2014)

Halfe said:
			
		

> How can I type in login credentials of the other server so I can connect.


You can't. There is no authentication in NFS. The client that does the mounting has to be @root.

And you also need to remove those two slashes in front of the hostname, it's not used. The correct command is something like this:
`mount_nfs myserver:/some/exported/dir /my/local/dir`


----------



## Halfe (Apr 3, 2014)

```
[root@DAVID] ~# mount_nfs 192.168.0.200:/Storage1 /mnt/MEDIA3/users/htpc/Media/Eventyrveien/
[tcp] 192.168.0.200:/Storage1: Permission denied
```


----------



## SirDice (Apr 3, 2014)

Ah, that just shows that it failed to use TCP. It's mounted but using UDP instead. NFS can operate on both UDP and TCP but the server may prefer one or the other.


----------



## Halfe (Apr 3, 2014)

```
mount_nfs -o udp 192.168.0.200:/Storage1 /mnt/MEDIA3/users/htpc/Media/Eventyrveien/
```


When using UDP I get this error:


```
[udp] 192.168.0.200:/Storage1/Media: RPCPROG_NFS: RPC: Program not registered
```


----------



## SirDice (Apr 3, 2014)

In that case it may be failing because of restrictions on the export. What does `showmount -e 192.168.0.200` show?


----------



## Halfe (Apr 3, 2014)

```
showmount -e 192.168.0.200                                    
Exports list on 192.168.0.200:
/mnt/Storage4/Media                192.168.0.0 192.168.0.14
/mnt/Storage3/Media                192.168.0.0 192.168.0.14
/mnt/Storage2/Media                192.168.0.0 192.168.0.14
/mnt/Storage1/Media                192.168.0.0 192.168.0.14
```


----------



## SirDice (Apr 3, 2014)

It looks like it allows access from the 192.168.0.0/24 network and 192.168.0.14 specifically. But you may want to verify that. What IP address does the client have?


----------



## Halfe (Apr 3, 2014)

The client is on another IP segment using an Ipsec tunnel. so it have 10.0.2.10. So basically I have to set up permission from my IP on the server?

Both are running FreeNAS 9.2.1.


----------



## SirDice (Apr 3, 2014)

Yes, the exports(5) file will need to allow access from that network segment. That's the reason why it's giving you a "permission denied". You have the "wrong" IP address according to NFS. It doesn't matter much what IP addresses are used on the tunnel, it's the client's own IP address that's important.


----------



## Halfe (Apr 3, 2014)

So if I insert my client's IP address that is 10.0.2.10 on the server on the other side of the tunnel that have 192.168.0.200 that will work. I just have to edit the exports list.

How do I do that?


----------



## SirDice (Apr 3, 2014)

No idea how to do that on FreeNAS. But yes, you need to add the 10.0.2.10 address to the server's exports(5) file. FreeNAS may have a nice editor for that, I don't know.


----------



## Halfe (Apr 3, 2014)

Can you show me how to do that from SSH?
FreeNAS and BSD are almost the same


----------



## SirDice (Apr 3, 2014)

Halfe said:
			
		

> Can you show me how to do that from SSH?


Sure, as @root just `vi /etc/exports` or `ee /etc/exports` (use ee(1) if you're not familiar with vi(1)). If you changed that file you need to tell NFS to re-read it: `pkill -HUP nfsd && pkill -HUP mountd`. Verify with the showmount(8) command to see if it's set correctly.


----------



## Halfe (Apr 3, 2014)

Thanks.

i asked on the FreeNAS forum but it was harder for me to get answer there.


----------



## SirDice (Apr 3, 2014)

Keep in mind that my instructions are guaranteed to work on FreeBSD, FreeNAS may not have everything FreeBSD has or it may be in a different location.


----------



## wblock@ (Apr 3, 2014)

Halfe said:
			
		

> Can you show me how to do that from SSH?
> FreeNAS and BSD are almost the same



No, they are not.  FreeNAS has a web-based config, and many FreeBSD commands have been removed.  If you try to do things as it if were FreeBSD, it may break the FreeNAS configuration.


----------

