Recently, we have been developing embedded projects and used file transmission between virtual machines and development boards. We chose NFS, but this problem always exists during use, the problem is still not mount. Today, I will summarize some of the problems and the basic configuration of NFS:
I. Concept of NFS
NFS (Network File System/network document system ):
1. configure file sharing between Linux systems (SAMBA service is required for file sharing between Linux and Windows );
2. NFS is only a document system. It has no transmission function and is implemented based on the RPC protocol to share the document directories between two Linux systems;
3. NFS is a C/S (Client/Server) architecture;
Ii. Server Configuration
1. configuration document
Main configuration documents:/etc/exports
Format: mount the Host IP address in the shared directory (parameter 1, parameter 2 ,......)
For example:/var/nfs 172. 20. *. * (RW, sync, all_squash, anonuid = 65534, anongid = 65534)
Note: you must pay attention to the NFS/directory access permission, which must be set to 777; the parent directory/var permission is not required, which can be a normal 755;
2. Start Related Services
Start related services in sequence: Portmap, nfslock, and NFS.
3. Check the shared directory
Then you can use showmount-e to check the shared directory:
[Root @ NS var] # showmount-e
Export list for NS. osserver:
/Var/nfs 172. 20 .*.*
OK. So far, the NFS server has been set up;
3. Client Configuration
1. Ensure Portmap operation
The client must ensure that the corresponding Portmap of the RPC protocol runs normally; otherwise, the Mount fails;
2. Mount the/var/NFS Directory (the local mount point is/mnt/NFS)
Mount-t nfs 172.20.65.16:/var/nfs/mnt/nfs
After mounting is successful, you can perform the same operations as the local directory;
4. Other related commands
1. After modifying the/etc/exports document, you can use exports-RV to re-export the shared directory without restarting the NFS service;
The command format is as follows:
Exportfs [-aruv]
-A: All content in Mount or unmount/etc/exports
-R: Re-mount the directory shared in/etc/exports
-U: umount directory
-V: Output detailed information to the screen during the export operation.
Example:
[Root @ NS var] # showmount-e
Export list for NS. osserver:
/Var/nfs 172. 20 .*.*
[Root @ NS var] # exportfs-Au # Uninstall all
[Root @ NS var] # showmount-e
Export list for NS. osserver:
[Root @ NS var] # exportfs-RV # Re-export all once
Exporting 172. 20. *. *:/var/nfs
[Root @ NS var] #
2. The showmout command is helpful for NFS operations and troubleshooting. Let's take a look at the usage of showmount.
Showmout
-A: this parameter is generally used on the NFS server and is used to display the Cline machine that has mounted the local NFS directory.
-E: displays the export directory on the specified NFS server.
For example:
[Root @ localhost ~] # Showmount-e 172.20.65.16
Export list for 172.20.65.16:
/Var/nfs 172. 20 .*.*
[Root @ NS var] # showmount-
All mount points on ns. osserver:
172. 20. *. *:/var/nfs
5. FAQs
1. Tip: Mount to NFS server '2017. ipv67.203 'failed: Server is down.
Solution: the NFS server firewall may be faulty;
2. Tip: Mount: RPC: timed out
Solution: Because the RPC protocol is not running, start the Portmap service;
It may also be a firewall problem; server/client may also be.
Here, I would like to mention that your DNS or gateway may be a ghost. I encountered such a problem at work. After all of the above tests, but NFS is still not easy to use, so you should ping a gateway or DNS. When my primary DNS is not good, NFS is not easy to use, adding a backup DNS server address is easy to use. I don't know what it is. I hope many Linux enthusiasts can give me some explanations. Thank you !!!!!