linux systems between them via the nfs network file system mount setup method

  • 2020-05-07 20:49:07
  • OfStack

NFS profile

NFS is short for Network File System, or network file system. By using NFS, users and programs can access files on remote systems as if they were local files 1.

NFS benefits

Here are the most obvious benefits of NFS:

1. The local workstation USES less disk space, because the usual data can be stored on one machine and accessed over the network.
2. The user does not have to have an home directory on every machine on the network. The Home directory can be placed on the NFS server and is available everywhere on the network.
Storage devices such as floppy drives, CDROM, and Zip can be used by other machines on the network. This reduces the number of removable media devices across the network.

Linux server 192.168.190.199 server
Linux server 192.168.190.208 client

192.168.190.199 (server) configuration operation:

1. Install services

Check to see if nfs, portmap services are installed

If nfs is not installed,portmap USES yum search < The package name > Install the appropriate package

2. The configuration/etc/exports

Configuration in the /etc/exports file

The configuration parameters are as follows

[Shared directory] [hostname 1 or IP1(parameter 1, parameter 2)] [hostname 2 or IP2(parameter 3, parameter 4)]

Here are some common parameters Shared by NFS:

ro read-only access
rw read and write access
All sync data is written to the share on request
async NFS can request this before writing the data
secure NFS is sent via secure TCP/IP ports below 1024
insecure NFS is sent through ports above 1024
wdelay group write if multiple users want to write to the NFS directory (default)
no_wdelay if multiple users want to write to the NFS directory, write immediately. This setting is not required when async is used.
hide does not share subdirectories in the NFS Shared directory
no_hide shares subdirectories of the NFS directory
subtree_check forces NFS to check the permissions of the parent directory (default) if a subdirectory such as /usr/bin is Shared
no_subtree_check as opposed to above, does not check the parent directory permissions
all_squash Shared files UID and GID map anonymous users anonymous, suitable for public directories.
no_all_squash reserve UID and GID for Shared files (default)
All requests for root_squash root users map to permissions like anonymous user 1 (default)
The no_root_squas root user has full administrative access to the root directory
anonuid=xxx specifies UID for the anonymous user in the NFS server /etc/passwd file
anongid=xxx specifies GID for the anonymous user in the NFS server /etc/passwd file

Such as:


/home/share208 192.168.190.208(rw,sync) *(ro)  Configuration description:   right 192.168.102.15 Read and write permissions are granted, other machines have only read - only permissions. 

3. NFS service

Start the NFS service


/etc/init.d/portmap start
/etc/init.d/nfs start

Discontinue NFS service


/etc/init.d/nfs stop
/etc/init.d/portmap stop

Restart the NFS service


/etc/init.d/nfs restart
/etc/init.d/portmap restart

Check the status of portmap and nfs services


/etc/init.d/portmap status
/etc/init.d/nfs status

Set the NFS service to start automatically

For a real-world Linux system, it is not practical to manually start nfs services every time you boot up, you should set the system to automatically start portmap and nfs services at the specified run levels (usually 3 and 5).


chkconfig  � level 35 portmap on
chkconfig  � level 35 nfs on

Execute the "ntsysv" command to launch the service configurator, locate the "nfs" and "portmap" services, prefix them with "*", and select "ok".

4.192.168.190.208 (customer service side) configure the client side

Creates a folder under the specified directory to mount the server folder


mkdir  � p /home/share208
mount 192.168.190.199:/home/share208 /home/share208 ( mount )

5. Test mount


192.168.190.208 /home/share208  Create a directory  test
192.168.190.199 /home/share208  Check that there is already test  directory 

Test successful.


Related articles: