Brief Introduction to the installation and configuration of the NFS service in Linux, and brief introduction to the Linux NFS service
Brief Introduction of NFS service installation and configuration in Linux
I have previously reproduced the same article. The article is very detailed and comprehensive, but it is complicated at the same time. After configuring nfs for Ubuntu and a development board, we will summarize the features for later users.
Development Board:
Debian GNU/Linux 7.5 (wheezy)
Ubuntu: Ubuntu 14.04.1 LTS
In Ubuntu, nfs is compiled into the OS as a module in the system. We do not need to configure it ourselves. It is also used as a startup service and does not need to be started. In the Debian system, nfs is not compiled into the system. At this time, we need to configure this module in linux_kernel.
1. Configure the nfs module in linux
In the. config file of linux_kernel or make menuconfig file, Configure nfs configurations in file System and Networking so that nfs can be compiled into the System.
Ii. Configure nfs-Related Files
After confirming that the system has an nfs module, we can start this service. However, before starting, we need to make some configuration. The configuration is relatively simple and involves three files:
/Etc/exports: Specifies the directory file of the folder shared by the nfs service and the permission used to share the file.
/Etc/hosts. deny: literally, the host is denied (identified by IP addresses) from connecting to the server. That is to say, you are not allowed to connect to the host list through nfs.
/Etc/hosts. allow: Same as above, which is the list of allowed connections
The above three files are the nfs configuration files. Even if the nfs service has been installed on Ubuntu, no configuration is provided.
Iii. Start the nfs service
Start the nfs service after the service is configured
/Etc/init. d/directory: nfs-kernel-server start
With this command, we can see that the nfs service shares the folders defined in/etc/exports. If the exports file is modified later, restart the nfs service in the/etc/init. d/folder:
/Etc/init. d/directory: nfs-kernel-server restart
4. Use the nfs service
After starting the nfs service, we can use our host as the server host of the nfs service to share the shared directory with other hosts installed with the nfs service. After the nfs service is installed on other hosts and the nfs service is enabled (no configuration is required, you only need to enable it, you can view the shared directory of the nfs server:
View the server shared directory as nfs: (other hosts): # showmount-e 172.16.11.220
The showmount command is not pre-installed on Ubuntu, so sudo apt-get install showmount to install this command. The following 172.16.11.220 is the IP address of the server that serves as the nfs server.
Use the nfs service to mount the server host: # mount 172.16.11.220:/home/wangzx/rootfs/home/usrname/nfs_test
This command is no different from the general mount command. Mount + IP address +: + shared directory of the server host local mount directory. This is basically OK
V. Example (taking Ubuntu 14.04 as an example)
The example starts with two machines with Ubuntu14.04. The intention is to use A as the server, B as the client, and configure the nfs environment in, then, use B to mount the directory shared by nfs in. The IP address of machine A: 172.16.11.220. B is 1721.16.11.157.
For:
1. the nfs service in Ubuntu14.04 is pre-installed, so we do not need to install it ourselves.
2. Configure the nfs file
Vim/etc/exports:
Add/home/wangzx/nfs * (rw, sync, no_root_squash, no_subtree_check)
Vim/etc/hosts. deny:
Add: portmap: ALL
Lockd: ALL
Mountd: ALL
Rquotad: ALL
Statd: ALL
Vim/etc/hosts. allow:
Add: portmap: 172.16.11.
Lockd: 172.16.11.
Rquotad: 172.16.11.
Mountd: 172.16.11.
Statd: 172.16.11.
This 172.16.11 is the ip address segment allowed to connect to the host through nfs. The ip address segment must comply with the ip address segment to connect to the host. Of course, it can be modified as needed. The specific meaning of the above modification parameters can refer to the article I previously forwarded: http://blog.csdn.net/feishangbeijixing/article/details/41246705
3. Start the nfs service
Go to/etc/init. d/run./nfs-kernel-server start to display that the service has started successfully.
For B:
The nfs service has been installed in Ubuntu14.04. In fact, all supporting tools such as portmap have been installed. Therefore, we only need to start B's Service (the nfs service of Ubuntu14.04 is automatically started upon startup), without any other configuration.
Run mount 172.16.11.220:/home/wangzx/nfs nfs_test on the port of machine B. In this way, the file directory/home/wangzx/nfs of machine A whose IP address is 172.16.11.220 is mounted to the local directory:/home/wangzx_mobile/nfs_test.
Now all nfs theories and practices are OK.