What do you do if you have a Windows client that you want to communicate with a Linux/Unix host? Many solutions...
are available for this type of configuration -- one of which is Samba, which uses SBM Protocol to establish these connections. However, if you want to establish communication between Linux and/or Unix servers, using Samba isn't necessary. Instead, you can use the Network File System (NFS) (using either TCP or UDP), which allows you to share files on a network as if they were on your local drive.
You will need to take several steps before you can use NFS. From your NFS server, you will need to export/share your directories. When this is completed, you will need to make sure the appropriate server services are all started, and only then can one go to the client to mount that directory. There are also various mount options that you should familiarize yourself with. Though there are other ways to configure your system to export/share directories/filesytems, The GUI utility in RHEL4 is one that you should start with. The command to bring it up is "system-config-nfs."
Editing the directory and host entries
When you first bring up the utility, you are already in the basic section, and you can start to edit your directory and host entries. In this example, one would be exporting the /oracle01/root directory on host testhost3. A quick glance at the basic permissions confirms that you will be allowing clients read-only access as well.
There are two other tabs here that you should be familiar with: "General" and "User Access." The General tab gives you the options to allow file locking, disable subtree checking and force syncing of write operations, among other things. The User Access tab gives you the ability to allow the remote root user to become root and also allows for various anonymous capabilities.
I would be extremely careful before clicking on any of these options without fully understanding what you will be doing. If you allow a remote user to become root, you may seriously compromise the overall integrity of your system.
When you are done configuring your options, click "ok." You will see the shared filesystem on the display. A quick glance at the actual file will let you confirm that the directory has been successfully edited. The file is /etc/exports.
One can either continue editing this file or use the GUI utility to make changes. I recommend the GUI for the beginner, though once the individual is more comfortable with NFS, then I would strongly suggest using more of the command line.
One must also remember to refresh the nfs daemon every time a change is made to the /etc/exports files. This is done by issuing the following command:
[[email protected] ~]# service nfs reload
The service command is a very useful utility which you will use to check status and/or recycle NFS where needed.
If you try to mount an NFS directory from a server that does not have services started, you will get RPC errors. To confirm NFS services, log on to the server, and issue:
[[email protected] ~]# service nfs status
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped
[[email protected] ~]#
One can determine from this output that the NFS daemons are not running.
Use the start command to start services.
The "OK" means that the daemons are up and running. The most important daemons are "mountd" and "nfsd." If your server must always function as an NFS server, make sure you enable the service to come up at boot time by using the "ckkconfig" command:
[[email protected] ~]# chkconfig --level 345 nfs on
NFS will now come up on the server.
Now let's mount. There are several ways one can mount and several types of mounts. You can mount directly from the command line:
[[email protected] ~]# mount redken:/oracle1 /mnt
This command will mount the oracle1 directory on system redken, to /mnt. Be careful when you do these mounts, because if you mount an external directory to a directory that you currently use, you may make that directory temporally unusable, and think that you have erased your data. There are many options you can use to establish mount points. One can even mount over UDP, which is a connectionless protocol, rather then through TCP. This option is included in RHEL4 kernel support. To mount using UDP, one would do this:
[[email protected] ~]# mount -o udp redken:/oracle1 /mnt
Another option, soft mounts, might be useful if you are concerned enough about the effects of mount points that might go away. Mounting soft will allow the system to behave more respectfully when losing mounts, as NFS is not happy when the mount point no longer exists.
mount -o soft [[email protected] ~]# mount -o soft redken:/oracle1 /mnt
You can also mount using the /etc/fstab file. One way to edit that file would be to use the fstab-sync command; the -a flag is used to add an entry.
Yet another option for using NFS is autofs, a separate service that enables you to manage mount points dynamically. This environment utilizes various maps to determine the appropriately defined mount points. Configuring autofs is a little more complicated and I would strongly suggest you brush up on your skills before setting up NFS using autofs, especially if it not necessary. The O'Reilly book Managing NFS and NIS, Second Edition can help you get started.