Network File System (NFS)NFS allows you to mount disks on remote systems so that they appear as though they are local to your system. Similarly, NFS allows remote systems to mount your local disk so that it looks as though it is local to the remote system. We'll go through a simple NFS server and client setup in this section after NFS background is supplied. You can use standard-mounted directories or automounted directories with NFS. Our upcoming example uses standard-mount directories but you can find out more about automounted directories and all NFS- related topics in Installing and Administering NFS Services from docs.hp.com. Configuring NFS to achieve this functionality is simple. Here are the steps to go through in order to configure NFS:
As with Internet Services, you could enable other aspects to NFS, but again, I cover what I know to be the NFS functionality that nearly every UNIX installation uses. Because NFS may be setup on your system to meet the needs of many users, you may want to understand the terminology associated with NFS. The following are commonly used NFS terms:
Some of the specific configuration tasks and related files are different among UNIX variants. The following are some general tasks and examples related to configuring NFS. Your system administrator, of course, has to deal with the specifics of configuration on the UNIX variants. Your system must be an NFS client, NFS server, or both. There are also daemons that must be running to support NFS. Both of these tasks are performed somewhat differently among the UNIX variants. Your system then imports remote file systems to which you have local access and exports local file systems that are accessed by other systems. A remote file system that you are mounting locally has an entry similar to the one that follows in /etc/fstab, /etc/filesystems , or whatever file is used to mount file systems: In this case, we are mounting /opt/app3 on system2 locally as /opt/app3 . This is an NFS mount with the permissions shown. You can use the showmount command to show all remote systems (clients) that have mounted a local file system. This command is supported on most UNIX variants. showmount is useful for determining the file systems that are most often mounted by clients with NFS. The output of showmount is particularly easy to read, because it lists the host name and the directory that was mounted by the client. You have the three following options to the showmount command:
Example NFS ConfigurationLet's take a look at the steps to setup an NFS server and client. We'll perform the following steps on our NFS server, with hostname asodevlab1 , to export the directory /home/frame :
You can also run showmount -e to see the mounted file system. We have performed all of the setup required on our server to export this file system. Next we'll proceed to the client part of the setup. The first step is to update the /etc/rc.config.d/nfsconf conf file to enable the NFS client. On our client, with hostname of m4415mxp , we'll enable both the NFS server and client as we did on the server.
The /home/frame directory will be automatically mounted at the next boot. We have to run the mount command as shown below to manually mount the file system at this time: # mount /home/frame # bdf Filesystem kbytes used avail %used Mounted on /dev/vg00/lvol3 409600 69466 318923 18% / /dev/vg00/lvol1 299157 26357 242884 10% /stand /dev/vg00/lvol8 4706304 146362 4275401 3% /var /dev/vg00/lvol7 1036288 748400 269946 73% /usr /dev/vg00/lvol5 409600 1388 382763 0% /tmp /dev/vg00/lvol6 3047424 749463 2154357 26% /opt /dev/vg00/lvol4 409600 1210 382871 0% /home asodevlab1:/home/frame 20480 1128 18144 6% /home/frame # ls -l /home/frame total 20 -r--r--r-- 1 root sys 959 May 6 12:14 copy.l.pm.Z -r--r--r-- 1 root sys 2570 May 6 12:14 copy1.xwd -r--r--r-- 1 root sys 2574 May 6 12:14 copy_done.xwd -r--r--r-- 1 root sys 2575 May 6 12:14 copy_sched.xwd # We manually mounted /home/frame , ran bdf to get information on all mounted file systems, and then ran ls -l to see its contents. Keep in mind that our client is accessing data on a server. We can write to this directory and the data will be written on the server. The nfsstat -m command can also be used to verify active NFS client mounts and options. Useful data on the NFS server is also provided by this command. There are many NFS mount options and trade-offs related to standard-mounting vs. automounting that are not covered in this book that are covered in Installing and Administering NFS Services . This example; however, shows how simple it is to get NFS mounts up-and-running quickly on two systems. With PCNFSD running, the PC NFS daemon, you can also mount this directory from a PC. |