In linux, the remote disk is mounted to the local disk through NFS, And the linuxnfs disk is mounted.
-
Recently, due to project reasons, we need to connect to the other two companies and retrieve the image data from the server of the other party. The original agreement was that the third party communicated through the http protocol, but the other party did not cooperate, the files are stored on their servers. Therefore, you can attach the disk of the server to a local device to obtain the disk.
-
-
Network File System (NFS) is a Network File System Supported by FreeBSD. It allows computers in the Network to share resources through TCP/IP networks. In NFS applications, local NFS client applications can transparently read and write files on the remote NFS server, just like accessing local files.
-
The two linux environments in this article are
CentOS and Ubuntu, Similar to other versions.
-
Mount/home/dhcc/nfs in Ubuntu to/home/shao/nfs in CentOS.
-
-
Ubuntu:
-
1. install and configure the NFS server
-
Sudo apt-get install nfs-kernel-server nfs-common
-
2. Configure Parameters
-
Vim/etc/exports
-
Add a line to the end of the file. Do not add comments.
-
/Home/dhcc/nfs * (rw, sync, no_root_squash) # This directory is the root directory of the nfs service. * indicates that all network segments can be accessed, or the specific IP address can be used, parameters are explained at the end
-
3. Create an nfs Directory (skip this step if an existing target is configured)
-
Sudo mkdir/home/dhcc/nfs
-
4. Check whether the configuration takes effect.
-
Exportfs-r# Update Configuration
-
Showmount-e
-
If it takes effect
-
Export list for Ubuntu:
-
Home/dhcc/nfs
-
5. Restart the nfs service.
-
/Etc/init. d/nfs-kernel-server restart
-
-
CentOS:
-
1. Create a mount directory (skip this step if it already exists)
-
Mkdir/home/shao/nfs
-
2. Install nfs-utils
-
Yum install nfs-utils
-
2. mount
-
Mount-t nfs 10.18.105.116:/home/dhcc/nfs/home/shao/nfs# The Ubuntu ip address is 10.18.105.116
-
3. automatic mounting upon startup
-
Vim/etc/rc. local
-
Add a row
-
Sudo mount-t nfs 10.18.105.116:/home/dhcc/nfs/home/shao/nfs
-
-
If the mount. nfs: access denied by server while mounting problem occurs, try the following methods:
-
1. Modify the nfs directory permission to be mounted.
-
Chmod 755/home/dhcc/nfs
-
2. If the port number is greater than 1024, add the insecure option to the configuration file (/etc/exports ):
-
Vim/etc/exports
-
Add the last line to the file
-
/Home/dhcc/nfs * (insecure, rw, sync, no_root_squash)
-
3. Modify the/etc/sysconfig/nfs file
-
# Turn off v2 and v3 protocol support # RPCNFSDARGS = "-N 2-N 3" # Turn off v4 protocol support # RPCNFSDARGS = "-N 4"/* put this sentence # Remove # */NFS is divided into three versions, that is, the NFS-2 NFS-3 NFS-4, which closes these three NFS versions by default, we just need to open the NFS-4.
-
Appendix: Common NFS parameters are as follows:
Ro read-only access
Rw read/write access to sync all data written and shared upon request
Async nfs can respond to requests before writing data
Secure nfs is sent through the secure TCP/IP ports below 1024
Insecure nfs is sent over port 1024
Wdelay if multiple users want to write data to the nfs Directory, group write (default)
No_wdelay if multiple users want to write data to the nfs Directory, write the data immediately. This setting is not required when async is used.
Hide does not share its subdirectories in the nfs shared directory.
No_hide shares the subdirectory of the nfs Directory
Subtree_check if sub-directories such as/usr/bin are shared, force nfs to check the permissions of the parent directory (default)
No_subtree_check is opposite to the above. The parent directory permission is not checked.
All_squash: The UID and GID of the shared file are mapped to the anonymous user anonymous, which is suitable for public directories.
No_all_squash retains the UID and GID of the shared file (default)
Root_squash all requests of the root user are mapped to the same permissions as those of the anonymous user (default)
The no_root_squas root user has full management access permissions to the root directory.
Anonuid = xxx specifies the UID of an anonymous user in the nfs server/etc/passwd file
Anongid = xxx specifies the GID of anonymous users in the nfs server/etc/passwd file