linux Construction NFS File Sharing Server Steps Detailed Explanation

  • 2021-08-12 04:15:30
  • OfStack

linux Build NFS Server

In order to realize data sharing in different operating systems, we will generally build a number of servers for file sharing, and nfs server is one of them, which realizes the sharing between linux and linux. Today, I will share the steps of how to build nfs server in linux system for your reference.

Building steps

1. Install the required software package for nfs


yum install rpcbind nfs-utils

2. Create test files and assign permissions


mkdir /home/test
chmod -R 777 /home/test/
cd /home/test/
vim aaa/bbb.txt  

3. Modify the configuration file


vim /etc/exports
 Write  /home/test 192.168.121.0/24(rw)   
 Shared file path   Allow shared network segments (shared file executable permission) 

 The executable permissions of shared files are: 
      ro            Read-only access 
      rw            Read-write access 
      sync           All data is written to the share on request 
      hide           In NFS Do not share its subdirectories in a shared directory 
      no_hide          Sharing NFS Subdirectories of directories 
      all_squash        Of shared files UID And GID Mapping anonymous users anonymous For public directories. 
      no_all_squash       Object that preserves shared files UID And GID (Default) 
      root_squash       root All requests of the user are mapped to such a anonymous Users 1 Sample permissions (default) 
      no_root_squas      root The user has full administrative access to the root directory 

4. Start the service


systemctl start rpcbind nfs

 Set boot and self-startup 
 echo "192.168.121.38:/home/test /nfs nfs4 defaults 0 0" >> /etc/fstab
 mount -av

5. View shared information


showmount -e 192.168.121.38  ( Here ip The address is the host address of the build server )

6. Access the nfs server
linux End Access:


mount 192.168.121.38:/home/test/ /mnt/
df

Summarize


Related articles: