---Oriental Oasis 2010-05-06
First, the environment
Server side: PC, Ubuntu10.04 operating system
Client side: ARM9 Development Board (2440)
Second, install NFS server program
The way to install NFS servers is simple, you can use the synaptic (new) package Manager to install, search for "NFS", select the package "Nfs-kernel-server" To install it, the following figure:
You can also install the NFS server program package by using the following command, which starts the SUNRPC service and the NFS service by default and creates the/etc/exports and Etc/default/nfs-kernel-server configuration files during command execution. After the user completes the NFS installation, configure the resources that will be shared.
You can use the netstat command to check whether an NFS port is open:
The above screenshot shows that the NFS and SUNRPC ports are already listening, but the client cannot access the NFS server at this time, and the Server for NFS is configured to authorize the shared resource to a specific user before the client can successfully access it.
Third, start and stop NFS services
Although NFS is started automatically after an NFS installation, the NFS service must be restarted to adjust the shared resources for the configuration to take effect.
1. Manually start and stop NFS services in a command mode
To start the NFS service:
To Stop the NFS service:
To restart the NFS service:
View the current status of the NFS service and return "NFSD running" If the NFS service is running. Otherwise, return "NFSD not running".
2, use graphics tools to start and Stop the NFS service (this item seems to be not in 10.04.) )
You can also use the Services-admin graphical interface tool to manage NFS services in Ubuntu. To start the NFS service at random startup, you can click on "System" | "System Management" | "Services" command, open the Service Settings dialog box, check the "Folder sharing Service (nfs-kernel-server)" option, and click the "Close" button to complete the setup.
Third, NFS server configuration
NFS services are open for users to share resources based on a "list".
1. NFS Service configuration file
In the Ubuntu Linux system,/etc/exports is the global configuration file for NFS servers. A row in the configuration file is a configuration item that indicates which clients share "which directory resources" on the network. The export resource configuration item format is as follows:
.......
Where the shared resource path is exported in the server, note: Must be an absolute pathname; the client host identity, which can be specified by host name, group, wildcard, network segment, or by space, if multiple host identities are assigned to each client host.
It's a good practice to put all the catalogs you need to export into the/etc/exports file, which can be clearer and clearer for NFS management. Try to make the details of the statement as detailed as possible, thus preventing intruders from entering the NFS service system.
2. Configure NFS Services with graphics tools (Ubuntu10.04 seems not to be found)
Configure Server for NFS in addition to using the text Editing tool, you can modify the/etc/exports file directly, and then restart the NFS service to complete the configuration task. You can also use the NFS Service Graphics Configuration tool provided by the Ubuntu Linux system for quick and easy configuration--shares-admin.
Step: Click System | System Management | The Shared Folders command to open the Shared Folders dialog box. Select the Add button to open the Share Folder dialog box to set up a variety of configuration options.
You'll find out after the configuration. The content of the/etc/exports configuration file is exactly the same as the configuration under the graphical interface.
If you modify only the/etc/exports file, you do not always restart the NFS service. You can use the Exportfs tool to reread the/etc/exports to load the output directory.
The Exportfs tool syntax is as follows:
Exportfs [-aruv]
-A: Mounts (or unloads) all/etc/exports settings.
-R: Re-mount the/etc/exports settings and update the contents of/etc/exports and/var/lib/nfs/xtab.
-U: Uninstall a directory.
-V: Displays the shared directory at the time of output.
If NFS is already started, if the/etc/exports file is modified again, you can execute the command:
$ exportfs-ra
Shared directory Access can be viewed in the System log file/var/lib/nfs/xtab, but only directories that are already mounted will appear in the log file.
Four, connect Server for NFS
With the above configuration, the client can mount the NFS shared resource locally by using the Simple Mount command, which can then be used as if it were a local file system.
1. View shared resources for Server for NFS
Before a client connects to an NFS shared resource, you typically use the Showmount command to view the shared resources on an NFS server to see if you have access. The Showmount command to see which NFS shared resources are on an NFS server. The Showmount command is included in the Nfs-kernel-server package, in general syntax format: showmount [DEHV] Nfssrvname
Where nfssrvname represents the Server for NFS hostname, the available IP address options are as follows:
-D: Displays shared directories that are mounted by the client
-E: Displays a list of exported shared Directories for NFS services
-H: Display Help information
-V: Display version
Using the Showmount command alone, the shared configuration entry in the local host/etc/exports configuration file is displayed.
2. Mount shared resources
The Mount command allows you to mount a shared resource on the server Side of NFS on the client side. The general syntax format for the Mount command is:
Mount Nfssrvname:/share-directory/mnt-point
Where Nfssrvname represents the server host name for NFS, also available IP address; Share-directory represents the shared resource directory exported by NFS server, must be in absolute path, separated from Nfssrvname with ":" Number ; Mnt-point indicates where the shared resource will be mounted on the client host, and make sure that the Mount directory already exists before mounting.
If no authorization is granted on the NFS server, the client still forcibly mounts some shared directories, and the execution fails.
3. Uninstall shared resources
After using the NFS server share resource, it is recommended that you uninstall the NFS file system immediately. Uninstall command Umount General syntax format is:
Umount/mnt-point
Where Mnt-point represents the mount point of the shared resource at the client.
Note: The file system cannot be unloaded when a user is using a file on an installed shared directory (to exit under mount point to uninstall). If the user confirms it correctly, you can use the "umount-f" command to forcibly uninstall the shared directory.