# FreeNAS & FreeBSD



## sk8harddiefast (Apr 7, 2011)

Hi. I have set a FreeNAS server. Is running fine and I can get WebUI from My desktop. Now I want to mount FreeNAS hdd's on my desktop computer. According this: http://www.freebsd.org/doc/handbook/network-nfs.html I guess that my desktop computer is NFS client and FreeNAS is the NFS server. So I set to /etc/rc.conf of my desktop computer 
	
	



```
nfs_client_enable="YES"
```
But Now what I must do? I have no idea and I am stuck.


----------



## Nukama (Apr 7, 2011)

Hi, 

check, that you've exported the appropriate file-systems inside FreeNAS (ask in the FreeNAS forum for help on configuring FreeNAS for your purpose).
setup and user guide:nfs
setup and user guide:services nfs shares
setup and user guide:nfs client


On your FreeBSD client add following to
/etc/rc.conf

```
#
# NFS Client
#
nfs_client_enable="YES"
nfs_client_flags="-n 4"
rpc_lockd_enable="YES"
rpc_statd_enable="YES"
```

And insert the mount points corresponding to your nfs exports() list (/etc/exports on your FreeNAS) to /etc/fstab for permanent use.
Use IP-Addresses if you have no name resolution, otherwise use a DNS server/forwarder or add the FreeNAS IP to your /etc/hosts.

/etc/fstab

```
FreeNAS.localdomain:/path/to/nfsshare /mnt     nfs     rw      0       0
```

Start nfs on the client:
`# nfsiod -n 4`

Mount filesystems from /etc/fstab:
`# mount -a`

Mount single filesystem which is exported from your FreeNAS box:
`# mount -t nfs FreeNAS.localdomain:/path/to/nfsshare /mnt`

Look out for the right UserID and GroupID or you run into trouble with permissions.


----------



## sk8harddiefast (Apr 7, 2011)

Ok. I made a step.
My /etc/rc.conf

```
nfs_client_enable="YES"
nfs_client_flags="-n 4"
rpc_lockd_enable="YES"
rpc_statd_enable="YES"
```
My /etc/hosts

```
<<<<<<< current version
::1			localhost localhost.lucifer
127.0.0.1		localhost localhost.lucifer
192.168.1.2		darkchaos.lucifer darkchaos
192.168.1.2		darkchaos.lucifer.
[B]192.168.1.3		FreeNAS.localdomain[/B]
=======
# $FreeBSD: src/etc/hosts,v 1.16.34.1.6.1 2010/12/21 17:09:25 kensmith Exp $
#
# Host Database
#
# This file should contain the addresses and aliases for local hosts that
# share this file.  Replace 'my.domain' below with the domainname of your
# machine.
#
# In the presence of the domain name service or NIS, this file may
# not be consulted at all; see /etc/nsswitch.conf for the resolution order.
#
#
::1			localhost localhost.my.domain
127.0.0.1		localhost localhost.my.domain
#
# Imaginary network.
#10.0.0.2		myname.my.domain myname
#10.0.0.3		myfriend.my.domain myfriend
#
# According to RFC 1918, you can use the following IP networks for
# private nets which will never be connected to the Internet:
#
#	10.0.0.0	-   10.255.255.255
#	172.16.0.0	-   172.31.255.255
#	192.168.0.0	-   192.168.255.255
#
# In case you want to be able to connect to the Internet, you need
# real official assigned numbers.  Do not try to invent your own network
# numbers but instead get one from your network provider (if any) or
# from your regional registry (ARIN, APNIC, LACNIC, RIPE NCC, or AfriNIC.)
#
>>>>>>> 8.2-RELEASE
```

My /etc/fstab

```
# Device			       Mountpoint		            FStype		Options		Dump	Pass#
/dev/ad14s1b			          none			swap		sw		0	0
/dev/ad14s1a			          /			              ufs		rw		1	1
/dev/ad14s1d			         /tmp			ufs		rw		2	2
/dev/ad14s1f			         /usr			ufs		rw		2	2
/dev/ad14s1e		 	         /var			ufs		rw		2	2
/dev/ad10s1d            	                       /mnt/1000       	              ufs     	              rw                        1            1
/dev/ad16s1d            	                       /mnt/1500       	              ufs                   	rw                        1             1
/dev/cd0			                       /cdrom			cd9660		ro,noauto	0	0
/dev/acd0		                      /cdrom1			cd9660		ro,noauto	0	0
linproc 			                      /compat/linux/proc 	              linprocfs 	rw 		0	0
linsys  		                                    /usr/compat/linux/sys               linsysfs     	rw   		0	0
proc  			                      /proc  			procfs  	              rw 		0	0
[B]FreeNAS.localdomain:/mnt/80g     /mnt/80                           nfs 		rw 		0         0[/B]
```

But 
	
	



```
mount -a
```


```
[tcp] FreeNAS.localdomain:/mnt/80g: RPCPROG_NFS: RPC: Program not registered
```


----------



## SirDice (Apr 7, 2011)

Looks like nfsd and/or mountd isn't running on the server.

Have a look with `# rpcinfo FreeNAS.localdomain`

Then check if the filesystems are exported correctly:
`# showmount -e FreeNAS.localdomain`


----------



## sk8harddiefast (Apr 7, 2011)

```
rpcinfo FreeNAS.localdomain
```
 Return:

```
program version netid     address                service    owner
    100000    4    tcp       0.0.0.0.0.111          rpcbind    superuser
    100000    3    tcp       0.0.0.0.0.111          rpcbind    superuser
    100000    2    tcp       0.0.0.0.0.111          rpcbind    superuser
    100000    4    udp       0.0.0.0.0.111          rpcbind    superuser
    100000    3    udp       0.0.0.0.0.111          rpcbind    superuser
    100000    2    udp       0.0.0.0.0.111          rpcbind    superuser
    100000    4    tcp6      ::.0.111               rpcbind    superuser
    100000    3    tcp6      ::.0.111               rpcbind    superuser
    100000    4    udp6      ::.0.111               rpcbind    superuser
    100000    3    udp6      ::.0.111               rpcbind    superuser
    100000    4    local     /var/run/rpcbind.sock  rpcbind    superuser
    100000    3    local     /var/run/rpcbind.sock  rpcbind    superuser
    100000    2    local     /var/run/rpcbind.sock  rpcbind    superuser
    100005    1    udp6      ::.3.239               mountd     superuser
    100005    3    udp6      ::.3.239               mountd     superuser
    100005    1    tcp6      ::.3.239               mountd     superuser
    100005    3    tcp6      ::.3.239               mountd     superuser
    100005    1    udp       0.0.0.0.3.239          mountd     superuser
    100005    3    udp       0.0.0.0.3.239          mountd     superuser
    100005    1    tcp       0.0.0.0.3.239          mountd     superuser
    100005    3    tcp       0.0.0.0.3.239          mountd     superuser
```
and 
	
	



```
showmount -e FreeNAS.localdomain
```
 Return:

```
Exports list on FreeNAS.localdomain:
/mnt/80g                           192.168.1.0
```

My FreeNAS have this IP: 192.168.1.3


----------



## SirDice (Apr 7, 2011)

There's no nfsd running on the server, hence no exports.


----------



## sk8harddiefast (Apr 7, 2011)

> There's no nfsd running on the server, hence no exports.


That means? What I must do? First time try to do this so, I just learn


----------



## Nukama (Apr 7, 2011)

In your /etc/rc.conf comment out following (stop the services/restart FreeBSD):

```
#rpc_lockd_enable="YES"
#rpc_statd_enable="YES"
```

Maybe FreeNAS isn't concerned about file locking.


----------



## SirDice (Apr 7, 2011)

No idea how to turn it on with FreeNAS. On FreeBSD you'd add something like this to /etc/rc.conf:


```
nfs_server_enable="YES"
```

Or everything:

```
rpcbind_enable="YES"
mountd_enable="YES"
rpc_statd_enable="YES"
rpc_lockd_enable="YES"
nfs_server_enable="YES"
```


----------



## SirDice (Apr 7, 2011)

Oh, in case you started things by hand, make sure to start rpcbind first. Both mountd and nfsd need to register their RPC.


----------



## sk8harddiefast (Apr 7, 2011)

Pfff  I tried the last 2 post but I get the same 
On boot say: NFS server:   ......re0 link up (That means that try to connect to FreeNAS)
But again return 
	
	



```
[tcp] FreeNAS.localdomain:/mnt/80g: RPCPROG_NFS: RPC: Program not registered
```
. And I tried all options 
Is everything on my fstab and hosts file fine? To be sure that the problem is not there.


----------



## Nukama (Apr 7, 2011)

Maybe /etc/hosts.allow on FreeNAS will help, if it's not related to statd and lockd, which must run on both server and client to enable file locking and will refuse to connect, if it is only configured on the client.

@SirDice:
nfsd is running on the FreeNAS box

```
Exports list on FreeNAS.localdomain:
/mnt/80g                           192.168.1.0
```

But should be 

```
Exports list on FreeNAS.localdomain:
/mnt/80g                           192.168.1.0/24
#or with the client IP
/mnt/80g                           192.168.1.2
```
 to allow the mount.


----------



## sk8harddiefast (Apr 7, 2011)

Also I change a little my /etc/hosts.allow


```
#
# hosts.allow access control file for "tcp wrapped" applications.
# $FreeBSD: src/etc/hosts.allow,v 1.23.10.1.6.1 2010/12/21 17:09:25 kensmith Exp $
#
# NOTE: The hosts.deny file is deprecated.
#       Place both 'allow' and 'deny' rules in the hosts.allow file.
#	See hosts_options(5) for the format of this file.
#	hosts_access(5) no longer fully applies.

#	 _____                                      _          _
#	| ____| __  __   __ _   _ __ ___    _ __   | |   ___  | |
#	|  _|   \ \/ /  / _` | | '_ ` _ \  | '_ \  | |  / _ \ | |
#	| |___   >  <  | (_| | | | | | | | | |_) | | | |  __/ |_|
#	|_____| /_/\_\  \__,_| |_| |_| |_| | .__/  |_|  \___| (_)
#					   |_|
# !!! This is an example! You will need to modify it for your specific
# !!! requirements!


# Start by allowing everything (this prevents the rest of the file
# from working, so remove it when you need protection).
# The rules here work on a "First match wins" basis.
ALL : ALL : allow

# Wrapping sshd(8) is not normally a good idea, but if you
# need to do it, here's how
#sshd : .evil.cracker.example.com : deny

# Protect against simple DNS spoofing attacks by checking that the
# forward and reverse records for the remote host match. If a mismatch
# occurs, access is denied, and any positive ident response within
# 20 seconds is logged. No protection is afforded against DNS poisoning,
# IP spoofing or more complicated attacks. Hosts with no reverse DNS
# pass this rule.
ALL : PARANOID : RFC931 20 : deny

# Allow anything from localhost.  Note that an IP address (not a host
# name) *MUST* be specified for rpcbind(8).
ALL : localhost 127.0.0.1 : allow
# Comment out next line if you build libwrap without IPv6 support.
ALL : [::1] : allow
#ALL : my.machine.example.com 192.0.2.35 : allow
[B]ALL : 192.168.1.0 : allow[/B]

# To use IPv6 addresses you must enclose them in []'s
#ALL : [fe80::%fxp0]/10 : allow
#ALL : [fe80::]/10 : deny
#ALL : [2001:db8:2:1:2:3:4:3fe1] : deny
#ALL : [2001:db8:2:1::]/64 : allow

# Sendmail can help protect you against spammers and relay-rapers
sendmail : localhost : allow
#sendmail : .nice.guy.example.com : allow
#sendmail : .evil.cracker.example.com : deny
sendmail : ALL : allow

# Exim is an alternative to sendmail, available in the ports tree
exim : localhost : allow
#exim : .nice.guy.example.com : allow
#exim : .evil.cracker.example.com : deny
exim : ALL : allow

# Rpcbind is used for all RPC services; protect your NFS!
# (IP addresses rather than hostnames *MUST* be used here)
#rpcbind : 192.0.2.32/255.255.255.224 : allow
#rpcbind : 192.0.2.96/255.255.255.224 : allow
[B]#rpcbind : ALL : deny
rpcbind : 192.168.1.0/255.255.255.0 : allow[/B]

# NIS master server. Only local nets should have access
# (Since this is an RPC service, rpcbind needs to be considered)
ypserv : localhost : allow
#ypserv : .unsafe.my.net.example.com : deny
#ypserv : .my.net.example.com : allow
ypserv : ALL : deny

# Provide a small amount of protection for ftpd
ftpd : localhost : allow
#ftpd : .nice.guy.example.com : allow
#ftpd : .evil.cracker.example.com : deny
ftpd : ALL : allow

# You need to be clever with finger; do _not_ backfinger!! You can easily
# start a "finger war".
fingerd : ALL \
	: spawn (echo Finger. | \
	 /usr/bin/mail -s "tcpd\: %u@%h[%a] fingered me!" root) & \
	: deny

# The rest of the daemons are protected.
ALL : ALL \
	: severity auth.info \
	: twist /bin/echo "You are not welcome to use %d from %h."
```


----------



## sk8harddiefast (Apr 7, 2011)

After rebooting NAS server I get this:

```
Mounting NFS file systems:re0: link state changed to UP
[tcp] FreeNAS.localdomain:/mnt/80g: RPCPROG_NFS: RPC: Port mapper failure - RPC:
 Timed out
```

Also I forgot to say that I use *FreeNAS-8.0-RC3-amd64*


----------



## sk8harddiefast (Apr 8, 2011)

Problem solved. NFS was not enable as service on NAS. Now is working. Thanks a lot on @Nukama for his help


----------

