BSD DevCenter
oreilly.comSafari Books Online.Conferences.

advertisement


FreeBSD Basics

Configuring and Using NFS

07/26/2000

In order to manipulate data using Unix, a file system that contains the data must first be mounted. If the data is located on a hard drive, floppy, or CD-ROM drive physically cabled to that computer, you can mount that device directly using the mount command to specify the device, the filesystem, and a local mountpoint. To automate this process, you can add the correct entry to your /etc/fstab file.

If you wish to access data that is physically located on another Unix computer, you will need to use NFS, the Network File System. The computer where the data is physically located must be running nfsd, the NFS daemon. It must also have a properly configured configuration file which is read by nfsd; this file is called /etc/exports.

The computer that wishes to access the remote data must be running the NFS client and must be mentioned in the /etc/exports of the computer running nfsd.

The easiest way to install nfsd and the nfs client is through /stand/sysinstall. Let's pretend I want a computer named alpha that has an IP address of 10.0.0.1 to access the /usr directory on a computer named gamma that has an IP address of 10.0.0.3. Gamma needs the nfsd, and alpha needs the nfs client. Let's start by logging on as root at gamma. Then type:

/stand/sysinstall

and select "Configure" and then "Networking." Press the space bar on the option "NFS Server" to select it. You will receive a message that will invoke the vi editor to edit /etc/exports.

The examples given in the default /etc/exports are straightforward enough to get NFS up and running. If you want to fine-tune NFS and gain a better understanding of it, open up another virtual terminal and type:

man exports

For now, let's just see if we can get NFS to work. Arrow down to the # in the line:

#/usr		huey louie dewie

press Esc-x to remove the #, arrow over to the "h" in huey and continue to press "x" to remove huey louie dewie. Press Esc-i and type alpha -- the line should now look like this:

/usr		alpha

Then press Esc and :wq to save your changes and quit the editor. Exit out of /stand/sysinstall.

We now need to start the nfsd. Press Alt-F1 to return to the main terminal, then type:

shutdown now
Press Enter when you get this message:
Enter full pathname of shell or RETURN for /bin/sh:

Then type:

exit

This causes FreeBSD to restart all of your daemons and reread their configuration files. Your startup messages should include the following:

Mounting NFS file systems.
Doing additional network setup: portmap
Starting final network daemons: mountd nfsd rpc.statd.

If you receive an error message instead, you may have disabled the portmap daemon in rc.conf.

If so, login as root and edit the rc.conf file:
pico /etc/defaults/rc.conf

Press Ctrl-W and type portmap to search for the portmap_enable line, which should read:

portmap_enable="YES"  #Run the portmapper service (or NO).

If it is set to NO instead, change the NO to YES, and check your change very carefully before saving it.

Issue another shutdown now, as above, and watch your boot messages. To ensure that nfsd did start, you can enter this command:

ps -aux

and look for the lines:

USER   PID %CPU %MEM   VSZ RSS TT STAT STARTED TIME    COMMAND
daemon 117 0.0  0.5    884 132 ?? Is   8:34AM  0:00.01 /usr/sbin/portma
root   122 0.0  0.7    488 184 ?? Is   8:34AM  0:00.02 mountd -r
root   124 0.0  0.0    328   0 ?? Is   8:34AM  0:00.01 nfsd: master (nf
root   126 0.0  0.0    320   0 ?? I    8:34AM  0:00.00 nfsd: server (nf
root   127 0.0  0.0    320   0 ?? I    8:34AM  0:00.00 nfsd: server (nf
root   128 0.0  0.0    320   0 ?? I    8:34AM  0:00.00 nfsd: server (nf
root   129 0.0  0.0    320   0 ?? I    8:34AM  0:00.00 nfsd: server (nf
root   130 0.0  0.5 263024 140 ?? Is   8:34AM  0:00.00 rpc.statd

The last thing we need to do on this computer is ensure there is an entry for alpha in /etc/hosts.

pico /etc/hosts
10.0.0.1	alpha

Let's also test connectivity:

ping 10.0.0.1

and

ping alpha

should both be successful.

Pages: 1, 2

Next Pagearrow





Sponsored by: