Mounting an NFS File System to ECSs (Linux)
After creating a file system, you need to mount it to ECSs so that they can share the file system.
CIFS file systems cannot be mounted to Linux ECSs.
An SFS Capacity-Oriented file system can use either the NFS or CIFS protocol. It cannot use both protocols.
In this section, ECSs are used as example servers. Operations on BMSs and containers (CCE) are the same as those on ECSs.
To use SFS Turbo as the storage backend for CCE, see Storage or Storage (FlexVolume). Then complete the deployment on the CCE console.
General purpose file systems cannot be mounted to 32-bit Linux servers.
Prerequisites
- You have checked the type of the OS on each ECS. Different OSs use different commands to install the NFS client.
- You have created a file system and have obtained its mount point.
- At least one ECS that is in the same VPC as the file system is available.
- The IP address of the DNS server for resolving the file system domain name has been configured on the ECSs. SFS Turbo file systems do not require domain name resolution.
- If you are mounting a general purpose file system, ensure that a VPC endpoint has been created according to Configure a VPC Endpoint.
Notes and Constraints
This constraint only applies to local paths (mount points) and does not affect other files or directories.
Metadata of the local paths (mount points) cannot be modified. Specifically, the following operations cannot be performed on the local paths' metadata:
- touch: Update file access time and modification time.
- rm: Delete files or directories.
- cp: Replicate files or directories.
- mv: Move files or directories.
- rename: Rename files or directories.
- chmod: Modify permissions on files or directories.
- chown: Change the owners of files or directories.
- chgrp: Change the group of a file or directory.
- ln: Create hard links.
- link: Create hard links.
- unlink: Delete hard links.
The atime, ctime, and mtime attributes of a local path (root directory of the mount point) are the current time. So each time the root directory attribute is queried, the current time of the server is returned.
Procedure
- Log in to the ECS as user root.
- Install the NFS client.
- Install the NFS client.
- Check whether the NFS software package is installed.
- On CentOS, Red Hat, Oracle Enterprise Linux, SUSE, EulerOS, Fedora, or OpenSUSE, run the following command:
- On Debian or Ubuntu, run the following command:
If a command output similar to the following is displayed, the NFS software package has been installed and you can go to 3. If no such command output is displayed, go to 2.a.ii.- On CentOS, Red Hat, EulerOS, Fedora, or Oracle Enterprise Linux, the command output is as follows:
libnfsidmap nfs-utils
- On SUSE or OpenSUSE, the command output is as follows:
nfsidmap nfs-client
- On Debian or Ubuntu, the command output is as follows:
nfs-common
- Install the NFS software package.
The following commands require that ECSs be connected to the Internet. Or, the installation will fail.
- Check whether the NFS software package is installed.
- Install the NFS client.
- Check whether the domain name in the file system mount point can be resolved. SFS Turbo file systems do not require domain name resolution. Skip this step and directly mount the file system.
nslookup File system domain name
- A file system domain name (for example, sfs-nas1.xxxx.com) is just part of its mount point. Enter the domain name here, not the entire mount point.
- If the nslookup command cannot be used, install the bind-utils software package by running the yum install bind-utils command.
- If the domain name can be resolved, go to 4.
- If the domain name cannot be resolved, configure the DNS server IP address and then mount the file system. For details, see Configuring DNS.
- Create a local path for mounting the file system.
mkdir Local path
If there is any resource, such as a disk, already mounted on the local path, create a new path. (NFS clients do not refuse repeated mounts. If there are repeated mounts, information of the last successful mount is displayed.)
- Mount the file system to the ECS that belongs to the same VPC as the file system. You can now mount the file system to Linux ECSs using NFSv3 only.
Table 1 describes the variables.
To mount an SFS Capacity-Oriented file system, run the following command: mount -t nfs -o vers=3,timeo=600,noresvport,nolock Mount point Local path
To mount an SFS Turbo file system, run the following command: mount -t nfs -o vers=3,timeo=600,noresvport,nolock,tcp Mount point Local path
To mount a general purpose file system, run the following command: mount -t nfs -o vers=3,timeo=600,noresvport,nolock,proto=tcp Mount point Local path
After a mounted ECS is restarted, it loses the file system mount information. You can configure auto mount in the fstab file to ensure that an ECS automatically mounts the file system when it restarts. For details, see Mounting a File System Automatically.
Table 1 Parameter description Parameter
Description
vers
File system version. Only NFSv3 is supported currently, so the value is fixed to 3.
timeo
Waiting time before the NFS client retransmits a request. The unit is 0.1 second. The recommended value is 600.
noresvport
Whether the NFS client uses a new TCP port when it re-establishes a network connection to the NFS server.
It is strongly recommended that you use the noresvport option, which ensures that your file system remains uninterrupted after a network reconnection or recovery.
lock/nolock
Whether to use the NLM protocol to lock files on the server. If nolock is specified, the lock is valid only for applications on the same host. It is invalid for applications on any other hosts. The recommended value is nolock. If this parameter is not specified, lock is used by default. In this case, other servers cannot write data to the file system.
SFS Turbo and General Purpose File System do not support operations of non-local locks. If a client uses a non-local lock, it will experience slow writes due to the failure to obtain the lock. In this case, the nolock option needs to be specified to avoid such issues.
proto
Protocol used by NFS clients to send requests to the server. Both UDP and TCP protocols can be used.
General Purpose File System does not support UDP. Therefore, you need to set proto to tcp for general purpose file systems.
Mount point
For an SFS Capacity-Oriented file system, the format is File system domain name:/Path, for example, example.com:/share-xxx. For an SFS Turbo file system, the format is File system IP address:/, for example, 192.168.0.0:/.
For a general purpose file system, the format is File system domain name:/File system name, for example, example.com:/xxx.
See Figure 1.
NOTE:- Variable x is a digit or letter.
- If the mount point is too long to display completely, adjust the column width.
- Hover the mouse over the mount point to display the complete mount command.
Local path
Local path on the ECS used to mount the file system, for example, /local_path.
For more performance optimization mount options, see Table 2. Use commas (,) to separate parameters. The following command is an example:
mount -t nfs -o vers=3,timeo=600,nolock,rsize=1048576,wsize=1048576,hard,retrans=3,tcp,noresvport,ro,async,noatime,nodiratime Mount point Local path
Table 2 Mount options for performance optimization Parameter
Description
rsize
Maximum number of bytes in each read request that the client can receive when reading data from a file on the server. The actual data size is less than or equal to this parameter setting. The value of rsize must be a positive integral multiple of 1024. Specified values less than 1024 are automatically replaced with 4096, and values greater than 1048576 are automatically replaced with 1048576. By default, this parameter is set through a negotiation between the server and the client.
You are advised to set this parameter to the maximum value 1048576.
wsize
Maximum number of bytes in each write request that the client can send when writing data to a file on the server. The actual data size is less than or equal to this parameter setting. The value of wsize must be a positive integral multiple of 1024. Specified values less than 1024 are automatically replaced with 4096, and values greater than 1048576 are automatically replaced with 1048576. By default, this parameter is set through a negotiation between the server and the client.
You are advised to set this parameter to the maximum value 1048576.
soft/hard
Value soft indicates soft mounts. With soft specified, if an NFS request times out, the client returns an error to the calling program. Value hard indicates hard mounts. With hard specified, if an NFS request times out, the client continues to request until the request is successful.
The default value is hard.
retrans
Number of retransmission times before the client returns an error. Recommended value: 1
tcp/udp
If mountproto is not specified, the client will mount the file system using UDP first. If the UDP network is not connected, the client will mount the file system using TCP after freezing for several seconds.
The UDP port used for mounting is currently not enabled in the inbound rule of the security group, so you need to specify tcp when mounting the file system.
ro/rw
- ro: indicates that the file system is mounted as read-only.
- rw: indicates that the file system is mounted as read/write.
The default value is rw. If this parameter is not specified, the file system will be mounted as read/write.
noresvport
Whether the NFS client uses a new TCP port when it re-establishes a network connection to the NFS server.
It is strongly recommended that you use the noresvport option, which ensures that your file system remains uninterrupted after a network reconnection or recovery.
sync/async
Value sync indicates that data is written to the server immediately. Value async indicates that data is first written to the cache and then to the server.
Value async is recommended. Synchronous writes require that an NFS server returns a success message after all data is written to the server, which brings long latency.
noatime
If you do not need to record the file access time, set this parameter. This prevents overheads caused by frequent access to modify the time.
nodiratime
If you do not need to record the directory access time, set this parameter. This prevents overheads caused by frequent access to modify the time.
You are advised to use the default values for the parameters with no usage recommendations provided.
- View the mounted file system.
mount -l
If the command output contains the following information, the file system has been mounted.Mount point on /local_path type nfs (rw,vers=3,timeo=600,nolock,addr=)
- After the file system is mounted successfully, access the file system on the ECSs to read or write data.
If the mount fails or times out, rectify the fault by referring to Troubleshooting.
The maximum size of a file that can be written to an SFS Capacity-Oriented file system is 240 TB.
The maximum size of a file that can be written to an SFS Turbo file system is 32 TB, and that for an SFS Turbo Enhanced file system is 320 TB.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot