Setup NFS Server On FreeBSD

by
Share this Article: Facebook0Google+0Twitter8LinkedIn0Reddit0StumbleUpon0

Network File System(NFS) is a network file system protocol developed by Sun Microsystems in 1984, allowing a user on a client computer to access files over a network on other   networked Computer.

1. Setting up a FreeBSD NFS Server

In this how-to my testbox is running with FreeBSD with IP Address 192.168.1.117.

The first step to setting up a NFS server is to edit the /etc/rc.conf file and add the following lines:

nfs_server_enable="YES"
nfs_server_flags="-u -t -n 4"
rpcbind_enable="YES"
mountd_flags="-r"
mountd_enable="YES"

Next, you have to set up /etc/exports file to define which machines have permission to which folders.

/data1 -maproot=user1 host1 host2 host3
/data2 -alldirs host1 host2 host3
/data3 host2

In the above example,

The user1 of host1, host2 and host3 systems has been given privileges to the /data1 directory.

The /data2 and its sub-directories has been given read access to host1, host2 and host3 systems.

The /data3 has been read access to host2 system(make sure you replace hosts with your desired host names).

To start NFS on FreeBSD server, do:

 1 rpcbind
 2 nfsd -u -t -n 4
 3 mountd -r

2. Restarting the NFS Server

Once you have made changes to the exports file you need to restart NFS for the changes to take effect:

 1 kill -HUP `cat /var/run/mountd.pid`

3. Setup the FreeBSD NFS Client

You need to add the following lines to /etc/rc.conf.

nfs_client_enable="YES"
nfs_client_flags="-n 4"
rpc_lockd_enable="YES"
rpc_statd_enable="YES"

4. Mounting NFS Shares

Mounting can be done like below:

 # mount_nfs IP:/data1 /data1

5. Auto Mounting NFS Shares

NFS shares can be automatically mounted by editing  /etc/fstab file.

Example:

 server:/data1  /data1 nfs rw 2 2

6. Mount FreeBSD NFS Shares On Centos Clients

Install Some NFS tools and Libraries:

# yum install nfs-utils nfs-utils-lib

Mount and list the remote folder.

# mount -t nfs FreBSD-Unixmen:/data1 -o vers=3 /NFS
# ls /NFS/
testx testy testz

For questions please refer to our Q/A forum at : http://ask.unixmen.com/


Share this Article: Facebook0Google+0Twitter8LinkedIn0Reddit0StumbleUpon13