Mounting File Systems (Linux)
NFS
Step 1: Install NFS Client
-
Before installing the NFS client, please confirm that you are using the recommended kernel version according to the information in the Linux NFS client kernel defect section, otherwise the host may experience IO freezes.
If it is a CentOS host, execute the following command to install the NFS client:
sudo yum install nfs-utils
If it is an Ubuntu host, execute the following command to install the NFS client:
sudo apt-get install nfs-common
-
By default, the NFS client limits the number of concurrent NFS requests it can initiate, with a default limit of 2 concurrent requests. This significantly impacts performance. You can refer to how to modify the concurrent number of NFS requests? to modify it to improve performance.
Step 2: Mount File System
-
Operate according to the mount point information displayed in the “Manage Mount Points” operation. The following example demonstrates the mounting process using a file system with ID ufs-dh6tds, assuming its mount point IP is 10.8.0.1 (replace the example parameters with your actual file system ID and mount point IP during operation).
For the NFSv3 protocol, run the following command to mount:
sudo mount -t nfs -o rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport,nfsvers=3,proto=tcp,mountproto=tcp,nolock,noacl 10.8.0.1:/ /mnt
For the NFSv4 protocol, run the following command to mount:
sudo mount -t nfs -o rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 10.8.0.1:/ /mnt
The meanings of various parameters in the mount command are as follows:
Parameter/Option Name | Description |
---|---|
Mount Point | The entry point for accessing the file system. The UFS mount point is represented by an IPv4 address. |
rsize, wsize | It is used to specify the block size of data when interacting with the file storage server (in Bytes). It is recommended to set 1048576. |
hard | It instructs the NFS client to continue retrying operations to the remote file storage when it is temporarily unavailable, rather than returning an error to the upper layer application. It is recommended to enable this option, which can enhance the fault tolerance of long-running tasks and high-cost interruption operations to temporary failures on network and other aspects. |
timeo | The time that the NFS client waits before retrying the request to the remote file storage, in units of 0.1 seconds. It is recommended to set the value to 600. |
retrans | The number of retries of a request by the NFS client. It is recommended to set this to 2. |
noresvport | Use a new port during network interruption reconnection, which can reduce the probability of reconnection failure. It is recommended to enable it. |
Step 3: View Mount Result
- After executing the mount command, you can run mount -l or nfsstat -m to list the currently mounted file systems. If the target file system is included in the list, the mount is successful.
Step 4: Set Up Automatic Mounting
-
We can implement automatic mounting of NFS file systems by configuring the /etc/fstab file in the Linux system. v4 protocol automatic mounting
10.8.0.1:/ /mnt nfs rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev,noresvport 0 0
v3 protocol automatic mounting
10.8.0.1:/ /mnt nfs rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,nfsvers=3,proto=tcp,mountproto=tcp,nolock,noacl,_netdev,noresvport 0 0
The meanings of various parameters in the command are as follows:
Parameter/Option Name | Description |
---|---|
_netdev | Indicates that the file system to be mounted is a network file system, to prevent from mounting operation before the network is ready, which may cause the host to freeze when booting up. |
0 (first item after noresvport) | If the value is not 0, it indicates that the file system should be backed up by dump. For NAS service, this item is 0. |
0 (second item after noresvport) | Indicates whether to perform the fsck operation after booting. Since the UFS product guarantees data persistence and consistency by the server, it is not necessary to enable this option. |
SMB
Step 1: Install CIFS Client
-
Before installing the CIFS client, please confirm that you are using the recommended kernel version according to the information in the Linux CIFS client kernel defect section, otherwise the host may experience IO freezes.
If it is a CentOS host, execute the following command to install the CIFS client:
sudo yum install cifs-utils
If it is an Ubuntu host, execute the following command to install the CIFS client:
sudo apt-get install cifs-utils
Step 2: Mount File System
-
Operate according to the mount point information displayed in the “Manage Mount Points” operation. The following example demonstrates the mounting process using a file system with ID ufs-dh6tds, assuming its mount point IP is 10.8.0.1 (replace the example parameters with your actual file system ID and mount point IP during operation).
sudo mount -t cifs -o guest,uid=0,gid=0,rsize=1048576,wsize=1048576 //10.8.0.1/share /mnt
The meanings of various parameters in the mount command are as follows:
Parameter/Option Name | Description |
---|---|
guest | Only supports client mounting based on the NTLM authentication protocol. |
rsize,wsize | Used to specify the size of data blocks (in bytes) when interacting with the file storage server. It is recommended to set them to 1048576. |
uid | The user that the files belong to after a successful mount. If uid is not set, the default is uid=0. |
gid | The user group that the files belong to after a successful mount. If gid is not set, the default is gid=0. |
Step 3: View Mount Result
- After executing the mount command, you can run mount -l to list the currently mounted file systems. If the target file system is included in the list, the mount is successful.
Step 4: Set Up Automatic Mounting
-
You can configure the /etc/fstab file in the Linux system to enable automatic mounting of the SMB file system.
//10.8.0.1/share /mnt cifs guest,uid=0,gid=0,rsize=1048576,wsize=1048576 0 0