Configuration of NFS service in Embedded Linux

Source: Internet
Author: User
Tags nfsd

NFS Introduction

In the embedded system development processProgramThe compilation and execution processes are completed on the host machine and the target machine respectively. Therefore, real-time interaction between the host machine and the target machine can greatly improve the efficiency of embedded system development. Because the target machine also has an operating system, you can achieve real-time interaction through network sharing between different machines. NFS is short for Network File System. It was first developed by Sun in 1984 to allow different computer operating systems to share files with each other. NFS is very convenient to use, so it is quickly supported by most Unix/Linux systems and is also supported by iete (International Internet Engineering Group) to use the NFS service as rfc1904, rfc1813, and rfc3010 standards, you must start at least three system daemon processes. (1) RPC. nfsd As a basic NFS Daemon, the main function is to manage whether the client can log on to the server. (2) RPC. mountd It is an RPC installation daemon. Its main function is to manage NFS file systems. When the client successfully passes the RPC. after nfsd logs on to the NFS server, it must pass the File Permission verification, RPC, before using the files provided by the NFS server. MOUNTD reads the NFS configuration file/etc/exports to compare the client's permissions. (3) Portmap The main function of Portmap is to map ports. When the client tries to connect to and use the services (such as the NFS service) provided by the RPC server, Portmap will provide the port number corresponding to the service to the client, this allows the client to request services from the server through this port. It is worth noting that although Portmap is only used for RPC, it is essential for the NFS service. If Portmap is not running, the NFS client cannot find the shared directory from the NFS server. To check whether the NFS service is running properly, run the rpcinfo-p command. If the NFS service runs normally, you can view entries about daemon such as Portmapper in the command execution result. Install NFS related service programs on PC Main Software Package for NFS Installation Portmap-4.0-54.i386.rpm // provides Port port packages Nfs-untils-1.0.1-2.9.i386.rpm // NFS service pack
[Root @ localhost root] #Rpm-QA | grep Portmap // Check whether the Portmap package is installed [Root @ localhost root] #Rpm-QA | grep NFS // Check whether the NFS software package is installed [Root @ localhost root] # Mount/dev/CDROM/mnt/CDROM // If it is not installed, mount the first image disk of Red Hat Linux 9.0 to the virtual machine, and the two master installation packages are on the first image disk. [Root @ localhost RPMs] # cd/mnt/CDROM/RedHat/RPMS/ // Switch to the installation package directory, [Root @ localhost RPMs] # ls-L Portmap * // Display the installation package details starting with Portmap [Root @ localhost RPMs] # rpm-IVH portmap-4.0-54.i386.rpm // Install and display the installation process with a progress bar [Root @ localhost RPMs] # ls-L nfs-utils * // Similarly, display the NFS installation package [Root @ localhost RPMs] # rpm-IVH nfs-untils-1.0.1-2.9.i386.rpm // Install NFS [Root @ localhost RPMs] # ls-Redhat-config-nfs-1.0.4-5.noarch.rpm Decompression is the same. Enable NFS service [Root @ localhost root] #Service Portmap status // View the running status of the Portmap Port [Root @ localhost root] #Service NFS status // Check whether the NFS service is enabled [Root @ localhost root] #Service Portmap start // Start the Portmap service [Root @ localhost root] #Service NFS start // Start the NFS service. If the service is restarted, use the service NFS restart [Root @ localhost root] # rpcinfo-P // Display the NFS program version protocol port

Device = eth0 // device alias Bootproto = static // static type Ipaddr = 192.168.1.10 // ip address Netmask = 255.255.255.0 // Subnet Mask Network = 192.168.1.0 // Default Gateway Boradcast = 192.168.1.255 // broadcast address Plan the partitions or directories to be shared Create a main directory named arm2410cl in the root directory, and create a sub-directory named temp in arm2410cl. Basic: Directory: custom /Arm2410cl * (or default) All Hosts /Arm2410cl/temp 192.168.1.0/24 (or 192.168.1. *) specifies all hosts in the subnet /Arm2410cl/mail www.chen.com host with the specified domain name /Arm2410cl/samba * .chen.com all hosts in the specified domain /Arm2410cl/FTP 192.168.1.10 host with the specified IP Address Basic permissions: RO: Read-Only RW: read/write The two basic permissions are single-choice. If you select Ro, RW cannot exist. Similarly, RO cannot be selected when RW is selected. General options: Insecure: allow connections from ports higher than 1024 Insecure_locks: Allows Insecure File Locking. No_subtree_check: Disable subtree Query Sync: Synchronize write operations as required No_wdelay: Force synchronous write operation now User Access: No_root_squash: treats remote root users as local root users All_squash: treats all customer users as Anonymous Users Anonuid = xxx: Specifies the local user ID for anonymous users Anongid = xxx: Specifies the Local Group ID for anonymous users. Maintain the output directory list of the NFS service After you modify the content of the/etc/exports file, you do not need to restart the NFS service, but directly use the command exportfs to make the settings take effect immediately. The exportfs command is used to maintain the output directory list of the NFS service. The basic format of the command is as follows:

Exportfs [Option] The options are as follows. -A: output all directories set in the/etc/exports file. -R: re-read the settings in the/etc/exports file and make the settings take effect immediately without restarting the NFS service. -U: Stop outputting a directory. -V: displays the directory on the screen when outputting the directory. 1. output the shared directory again. After modifying the content of the/etc/exports file, you can use the following command to output the shared directory again. Exports -- RV 2. Stop outputting all shared directories To stop outputting all the shared directories of the NFS server on the current host, run the following command. Exportfs Run the showmount command to test the output directory status of the NFS server. The basic format of the showmount command is: Showmount -- e 192.168.1.10 Showmount The showmount command is as follows: # Showmount [-AE] hostname The parameters are described as follows. (1)-A: displays the client host name and mount point directory in the format of Host: Dir. (2)-D: Only displays the directory name mounted by the customer. (3)-E: displays the output list of the NFS server. (4)-H: displays help information. (5)-V: displays the version information. (6) -- no-headers: Disable the output of information about the description header. To scan the NFS shared directory provided by a host, use showmount-e IP (or host name hostname. # Netstat-utln//Observe the active port number
NFS is enabled on port 2049, and other ports are RPC server and other programs (such as RPC. MOUNTD and RPC. rquotad and RPC. NFSD .) randomly generated (that is, the port number is not fixed, and each restart NFS will get a different port number ). It is worth noting that when you use the showmount-e command to view the output directory on the NFS server, if the fault shown in 4-14 occurs, the reason may be that the Portmap or NFS service is not enabled on the NFS server, or the firewall may filter out the service. The solution is to start the Portmap or NFS service on the NFS server and reset the firewall (including iptables and TCP_WRAPPERS) on the NFS server ). To test the functions of the NFS server, you can simply use the service iptables Stop command to disable the firewall. If you do not want to turn off the firewall, you can also use rpc port 111 and NFS Start port 2049 to allow external access:

Iptables-A input-p tcp-M multiport -- dport 111,2049-J accept
Iptables-A input-p udp-M multiport -- dport 111,2049-J accept To enable automatic NFS connection at startup for the system to automatically mount the output directory on the NFS server at startup, edit the file/etc/fstab and add the following statements to the file: [Root @ localhost root] # Vim/etc/fstab NFS server name or IP Address: Local Mount directory of the output directory NFS ults 0 0 192.168.1.10:/arm2410cl/mnt/nfs NFS ults 0 0
Start a Super Terminal: Modify the IP address and subnet mask [Root @ embedsky/] #Ifconfig eth0 192.168.1.11 netmask 255.255.255.0
[Root @ embesky/] # Ping-C 4 192.168.1.10 // Ping is connected
[Root @ embesky/] #Mount-T NFS-O nolock 192.168.1.10:/arm2410cl/mnt/nfs The Mount directory is/arm2410cl of the client, and the mount point is/mnt/NFS on the Development Board.
Detach an NFS server [Root @ embedsky] # umount/mnt/nfs // The Mount directory cannot be detached. Otherwise, the system is busy and cannot be detached.
Troubleshooting of NFS servers Troubleshooting If NFS fails, you can check the problem from the following aspects. (1) Whether the NFS client and server load is too high, and whether the network between the server and the client is normal. (2) Correctness of the/etc/exports file. (3) restart the NFS or Portmap service if necessary. Run the following command to restart Portmap and NFS: Service Portmap restart Service NFS start (4) check whether the mount command or/etc/fstab syntax on the client is correct. (5) check whether the kernel supports NFS and RPC services. NFS error message. Portmap is disabled or blocked, or NFS service is not enabled.
Command error during mounting
The directory does not exist during mounting.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.