After you have finished with the /etc/exports file, you will check to see whether the NFS service is started by using the command:
# service nfs status
If you see a message saying that services are stopped, issue the following command:
# service nfs start
and watch as the related NFS services are started. When the services are started, you can enter the command
# /usr/sbin/exportfs -r
to export all the file systems in the /etc/exports file to a list named xtab under the /var/lib/nfs directory, which is used as a guide for mounting when a remote computer asks for a directory to be exported. The -r option to the command reads the entire /etc/exports file and mounts all the entries. The exportfs command can also be used to export specific files temporarily. Here's an example of using exportfs to export a file system:
# /usr/sbin/exportfs -o async yourhost:/usr/tmp
This command exports /usr/tmp to yourhost with the async option.
Be sure to restart the NFS server after making any changes to /etc/exports. If you prefer, you can use Fedora's system-config-nfs graphical client to set up NFS while using X. Start the client by going to System, Administration, Server Settings, NFS.
After you press Enter, you are prompted for the root password. Type in the password and click OK, and you see the main window. Click the Add button, and you see the Add NFS Share dialog box, as shown in Figure 19.1.
FIGURE 19.1 Fedora's system-config-nfs client can be used to quickly set up local directories for export via NFS.
In the Directory text box, type a name of a directory to be exported; in the Host(s) text box, type a hostname or the IP address of a remote host that is to be allowed access to the directory. By default, a directory is exported as read-only, but you can choose read and write access by clicking either option in the Basic Permissions area of the dialog box. When finished, click the OK button, click the Apply button, and then use the File menu to quit.
As part of your configuration for using NFS, you might need to enable the port on your firewall. Go to System, Administration, Firewall to open the Firewall configuration utility. Check the box next to NFS4 and click Apply to apply the new firewall policy.
NFS Client Configuration
To configure your host as an NFS client (to acquire remote files or directories), edit the /etc/fstab file as you would to mount any local file system. However, rather than use a device name to be mounted (such as /dev/sda1), enter the remote hostname and the desired file system to be imported. For example, one entry might look like this:
# Device Mount Point Type Options Freq Pass
yourhost:/usr/local /usr/local nfs nfsvers=4,ro 0 0
If you use autofs on your system, you need to use proper autofs entries for your remote NFS mounts. See the section 5 man page for autofs.
The options column uses the same options as standard fstab file entries with some additional entries, such as nfsvers=4, which specifies the fourth version of NFS. You can also use the mount command, as root, to quickly attach a remote directory to a local file system by using a remote host's name and exported directory. For example:
# mount -t nfs 192.168.0.11:/home/andrew \
/home/andrew/test/foo
After you press Enter, the entire remote directory appears on your file system. You can verify the imported file system by using the df command, like so:
# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
73575592 58627032 11150752 85% /
/dev/sda1 101086 18697 77170 20% /boot
tmpfs 512724 0 512724 0% /dev/shm
192.168.0.11:/home/andrew
35740416 5554304 28341248 17% /home/andrew/test/foo
Make sure that the desired mount point exists before using the mount command. When you finish using the directory (perhaps for copying backups), you can use the umount command to remove the remote file system. Note that if you specify the root directory (/) as a mount point, you cannot unmount the NFS directory until you reboot (because Linux complains that the file system is in use).
Putting Samba to Work
Samba uses the Session Message Block (SMB) protocol to enable the Windows operating system (or any operating system) to access Linux files. Using Samba, you can make your Fedora machine look just like a Windows computer to other Windows computers on your network. You do not need to install Windows on your PC.
Samba is a very complex program — so much so that the book Samba Unleashed (Sams Publishing, 2000, ISBN 0-672-31862-8) is more than 1,200 pages long. The Samba man page (when converted to text) for just the configuration file is 330KB and 7,013 lines long. Although Samba is complex, setting it up and using it does not have to be difficult. There are many options, which account for some of Samba's complexity. Depending on what you want, Samba's use can be as easy or as difficult as you would like it to be.
Fortunately, Fedora includes two tools: a simplified Samba management tool called system-config-samba, and a much more advanced tool known as SWAT (Samba Web Administration Tool), which can be used to configure Samba with a web browser. SWAT provides an easy way to start and stop the Samba server; set up printing services; define remote access permissions; and create Samba usernames, passwords, and shared directories. This section delves into the basics of configuring Samba, and you should first read how to manually configure Samba to get an understanding of how the software works. At the end of this section, you will see how to enable, start, and use SWAT to set up simple file sharing.
Like most of the software that comes with Fedora, Samba is licensed under the GPL and is free. It comes as both an RPM and as source code. In both cases, installation is straightforward and the software can be installed when you install Fedora or use RPM software packages. The Samba RPMs should be on one of your Fedora install disks, or the latest version can be downloaded from the Internet, preferably from the Fedora Project (at http://fedoraproject.org/) or an authorized mirror site.
Installing from source code can be more time-consuming. If you do not want to install from Fedora's default locations, however, installing from the source code is a more configurable method. Just download the source from http://www.samba.org/ and unpack the files. Change into the source directory and, as root, run the command ./configure along with any changes from the defaults. Then run make, make test (if you want), followed by make install to install Samba in the specified locations.