|
Linux Networking, Part 7: Implementing NFS
Sharing Data Between MachinesIf you have Windows PCs on your home network and have no pressing reason to use NFS (Network File System) support to share files, then read no farther. NFS is actually more robust than Samba, but it is also more complicated depending upon what features are used. From a basic point of view, NFS and Samba are very similar. Both have a client and server application. Both allow a server to share files with clients. Both have clients and servers on almost every platform. The big difference is the Windows PCs have Samba-compatible clients and servers as part of their default network support and Windows requires third party software to support NFS. Conversely, UNIX systems usually come with and use NFS by default with Samba being used to provide file sharing with Windows PCs. Perhaps the biggest difference between NFS and Samba is that NFS uses an explicit resource browser capability. This means that an NFS client can poll a particular server using the showmount program, as in showmount -e fileserver, to see what directories have been exported. Samba clients do this as well using NetBIOS but they can also determine what servers are available as well. The showmount program must be given the domain name or IP address of the server. This article covers the basics of NFS configuration. There are a number of NFS HOWTOs and books on NFS that are good sources of information in addition to the online manual pages for the applications mentioned in this article. These should be used if security is an issue. NFS works as well as Samba in providing file-sharing support in a closed network that is not connected to the Internet or one that has a good firewall in place. The Linux implementation of NFS tends to be relatively secure by default but it is possible to configure NFS servers, so there are open security holes. The Linux 2.2 kernel has NFS support built-in. The NFS client and server applications tap this support. The NFS server has multitasking support that provides better performance, although this feature is targeted at larger networks. NFS can be set up by editing the configuration files associated with the NFS support or running applications to mount or dismount an NFS directory. Most of the Linux setup applications, such as linuxconf found in Red Hat Linux, can also be used to configure the NFS server and client. It is possible to use both configuration approaches, but it is best to use one or the other unless you are familiar with how the setup application modifies the configuration files.
NFS Startup and Server SupportNFS client and server support is actually built into the Linux kernel. The NFS server application is named The NFS script only operates if the Dynamic sharing of directories is done by The first exports the directory The second instance of The The The first allows any user read-only access to the /home/guest directory. The second allows read-write access to computers with a domain name of local.dom and read-only access to everyone else.
The NFS client support is done using the Linux mount application. The following is a sample command line for mounting an NFS directory:
This command explicitly declares the type as NFS (-t nfs). The rsize and wsize options specify buffer sizes that should be multiples of 1024. They can be omitted but larger values reserve larger buffers than may improve performance. Other options allow a directory to be specified as read-only or they can prevent applications in the directory or subdirectories from running.
Dismounting a mounted NFS directory is done using the Mounting a shared directory can also be done when Linux starts up. In this case, an entry, like the following, is added to the The linuxconf program can be used to make modifications to the The NFS status application is named
|