network shared folder - liamlamth/blog GitHub Wiki

setup

## [root@server_being_mounted ~ ] yum install nfs-utils
## [root@server_being_mounted ~ ] systemctl status rpcbind                          ### if not started, then start and enable
[root@server_being_mounted ~ ] systemctl enable --now nfs-server
[root@server_being_mounted ~ ] vi /etc/exports
    /destfolder 192.168.1.100(rw,sync)                                           ### 192.168.1.100 is the server_to_mount
[root@server_being_mounted ~ ] exportfs -ra
## [root@server_being_mounted ~ ] exportfs -v

[root@server_to_mount ~ ] mount -t nfs 192.168.1.101:/destfoler /sourcefolder    ### 192.168.1.101 is the server_being_mounted
/etc/exports parameter
(1)  ro                      read-only to the shared folder
(2)  rw                      read-write to the shared folder
(3)  root_squash             when using root     to access to the shared folder, root user will map to the anonymous user
(4)  no_root_squash          when using root     to access to the shared folder, root user will map to the root user
(5)  all_squash              when using any user to access to the shared folder, any  user will map to the anonymous user
(6)  Anonuid                 when using any user to access to the shared folder, any  user will map to the specified user id
(7)  Anongid                 when using any user to access to the shared folder, any  user will map to the specified usergroup id
(8)  sync                    data will be synchronously written to the memory and disk
(9)  async                   data will be written to the memory first, then disk
(10) insecure                allow unauthorized access from this machine
(11) subtree_check           when sharing subdirectory under parent like /usr/bin, check parent directory permission
(12) no_subtree_check        when sharing subdirectory under parent like /usr/bin, do not check parent directory permission
(13) wdelay                  wait in order when multiple users are trying to write data
(14) no_wdelay               do not wait   when multiple users are trying to write data
(15) hide                    do not share subdirectories
(16) no_hide                 share subdirectories

startup auto-mounting

  • bg: if first mount request failed, it will retry mounting in background, default retry interval is every 2 min and retry for a week.
  • _netdev: delay mounting until network service is active.
[root@server_to_mount ~ ] vi /etc/fstab
  ...
  192.168.1.100:/volume1/DB_SERVER_BACKUP         /backup         nfs     defaults,bg,_netdev     0 0
  ...
  
⚠️ **GitHub.com Fallback** ⚠️