Table 221 etcfstab Options

Option Purpose rw Gives read and write access ro Gives read-only access async Writes data when the server, not the client, feels the need sync

Writes data as it is received

The following is an example of an /etc/exports file:

# /etc/exports: the access control list for filesystems which may be exported

# to NFS clients. See exports(5). /home/andrew,no_root_squash)

This file exports (makes available) /home/ahudson to any host in 192.168.2.* and allows users to read from and write to /home/ahudson.

After you have finished with the /etc/exports file, the following command sudo exportfs a exports 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. You can also use the exportfs command to export specific files temporarily. Here's an example 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 Ubuntu's shares-admin graphical client to set up NFS while using the X Window System. Start the client by clicking the System menu and then selecting the Shared Folders menu item from the Administration menu. You can also start the client from the command line of an X terminal window, like so:

$ gksudo shares-admin &

After you press Enter, you are prompted for your password. Type in the password and click OK; the main window will then display. Click the Add button to open the Add Share dialog box, as shown in Figure 22.1.

Figure 22.1. You can use Ubuntu's share-admin client to quickly set up local directories for export using NFS.

Figure 22.1. You can use Ubuntu's share-admin client to quickly set up local directories for export using NFS.

In the Path drop-down box, choose the directory that you want to share; in the Share drop-down box, choose NFS. Click the Add Host button that appears to specify which hosts, IP addresses, or networks to be allowed access to the directory. By default, a directory is exported as read/write, but you can choose read-only by ticking the Read Only option. When finished, click the OK button, click the Apply button, and then use the File menu to quit.

Was this article helpful?

0 0

Post a comment