blog.up-link.ro android bsd linux unix & open-source world

25Mar/100

How To Set Up a NFS Server in FreeBSD

WP Greet Box icon
Hello there! If you are new here, you might want to subscribe to the RSS feed or subscribe via E-mail for updates on this topic.

Network File System (NFS) is a network file system protocol originally developed by Sun Microsystems in 1984, allowing a user on a client computer to access files over a network in a manner similar to how local storage is accessed.

1. Setting up a NFS Server

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.  The exports file looks something like this:

/data -maproot=user1 host1 host2 host3
/backup -alldirs host1 host2 host3
/store host2

In this example the machines host1,host2 and host3 are given the privileges of the user1 for the /data directory.

For /backup they are given access to read from all directories within backup. And for /store only host2 is given access to read just the /store directory (make sure you replace hosts with your desired host names).

To start NFS server, enter:

rpcbind
nfsd -u -t -n 4
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:

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

3. Setting up 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.statd and rpc.lockd are required for proper NFS locking support on FreeBSD client systems.
rpc_lockd_enable="YES"
rpc_statd_enable="YES"

4. Mounting NFS Shares

Mounting can be done with the following command:

mount_nfs machine:dir localdirectory

For example if we are mounting the backup folder from the server in the example above to a folder called /localbackup on our machine it would look like this:

mount_nfs server:/backup /localbackup

5. Auto Mounting NFS Shares

NFS shares can be automatically mounted by putting them into /etc/fstab.

Example:

# Device Mountpoint FStype Options Dump Pass#
server:/backup /localbackup nfs rw 2 2

Print This Post Print This Post
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


*

No trackbacks yet.