Mounting and Using a General-Purpose File System on Linux ECSs
Scenarios
To use a general-purpose file system for file sharing, you need to create a general-purpose file system and mount it on multiple servers.
This section describes how to create an NFS general-purpose file system on the SFS console and mount it to Linux ECSs for file upload and download.
Operation Process
| Procedure | Description |
|---|---|
| Sign up for a Huawei Cloud account, complete real-name authentication, and top up your account. Then, create a VPC endpoint, VPC, and ECS. | |
| Create a general-purpose file system. | |
| Mount the general-purpose file system to the ECSs. | |
| Use the general-purpose file system for file upload and download. |
Preparations
- Sign up for an account and complete real-name authentication.
Before purchasing SFS, sign up for a Huawei Cloud account, and complete real-name authentication.
If you have enabled Huawei Cloud services and completed real-name authentication, skip this step.
- Add a credit card to your account.
Ensure that your account has sufficient balance or has a valid payment method configured. For details, see Top-Up and Payment.
- Create a VPC endpoint.
Before mounting a general-purpose file system, create a VPC endpoint by referring to Creating a VPC Endpoint. Alternatively, when creating the general-purpose file system, select Automatically Create a VPC Endpoint to let the system create one for you. For details, see Creating a General-Purpose File System.
- Create a VPC and ECSs.
Before creating a general-purpose file system, check whether a VPC and ECSs are available, and whether the ECSs are in this VPC. If they are in different VPCs, you can establish communication between SFS and the ECSs using VPC peering connections. For details, see VPC Peering Connection.
- Create a VPC.
Create a VPC by referring to Creating a VPC with a Subnet.
- Create ECSs.
Buy ECSs in CN-Hong Kong in the created VPC by referring to Purchasing and Using a Linux ECS.
Step 1: Creating a General-Purpose File System
File systems are containers that store files in SFS. You need to create a general-purpose file system before storing data in SFS.
This example covers only some key parameter settings. Retain the default values for other parameters. For more information, see Creating a General-Purpose File System.
- Log in to the SFS console.
- In the upper right corner of the page, click Create File System.
- Configure the parameters based on Table 1.

Table 1 Parameters for creating a general-purpose file system Parameter
Example
Description
Replicate Existing File System Settings
-
Optional. Click Select Source File System. On the displayed page, select a source general-purpose file system from the list. After you click OK, the system automatically copies the region, AZ, protocol, authorization, and tags of the source file system.
You can change some or all of the replicated settings, if needed.
Region
CN-Hong Kong
The region where the tenant belongs.
Select the region where the ECSs and VPC endpoint reside.
AZ
AZ1
An AZ is a physical location that uses independent power supply and networks. AZs in the same region can communicate with each other over an intranet.
For low network latency, you are advised to select the same AZ where the ECSs reside.
Name
sfs-name-001
The user-defined name of the general-purpose file system.
This name must be globally unique and cannot be the same as the name of any existing general-purpose file system, including one created by the current user or any other user. And it cannot be changed after the file system is created.
If a general-purpose file system is deleted, you can create a new file system with the same name after at least 12 hours.
The name can be 3 to 63 characters long and can contain only lowercase letters, digits, hyphens (-), and periods (.). It cannot start or end with a period (.) or hyphen (-), cannot contain IP addresses, and cannot contain two consecutive periods (..) or a period (.) and a hyphen (-) adjacent to each other.
Authorization
By VPC
You can select By VPC or By replication.
By VPC: Select the VPC where the ECSs and VPC endpoint reside. An ECS cannot access a file system in a different VPC. Select the VPC where your ECSs reside. You can add VPCs later on the file system details page.
By replication: This option is available after you select to replicate settings from a source file system.
VPC
-
If you select authorization by VPC, you need to manually select a VPC.
Select the IAM project to which the target VPC belongs and then select the target VPC. For details about IAM projects, see Project Management.
Select the VPC where the ECSs and VPC endpoint reside.
An ECS cannot access a general-purpose file system in a different VPC. Select the VPC where your ECSs reside. You can add VPCs later on the file system details page.
VPC Endpoints
-
After selecting a VPC, check whether there are VPC endpoints available for the general-purpose file system.
- If there are, the list displays the VPC endpoint IDs, route tables, and creation times. You can click a VPC endpoint ID and its route table to go to their basic information pages. The Automatically Create a VPC Endpoint option is disabled by default.
- If there are not, create a VPC endpoint manually or automatically.
- To manually create a VPC endpoint, click Create VPC Endpoint under the selected VPC.
- To automatically create a VPC endpoint, enable Automatically Create a VPC Endpoint. Once enabled, the VPC endpoint service name will be displayed.
Select route tables. If no route tables are available, click Create Route Table to create one.
CAUTION:- Automatically creating a VPC endpoint is only supported when you choose authorization by VPC.
- Creating VPC endpoints for general-purpose file systems is free of charge.
- If communication over the public network is abnormal, check whether the VPC endpoint is correctly created and whether your ECSs are in the same subnet as the one associated with the VPC endpoint's route table.
- Click Create Now.
- Confirm the file system information and click Submit.
- Go back to the general-purpose file system list.
If you can see the general-purpose file system in the list, it is created successfully. If not, the creation fails. Submit a service ticket for technical consultation.

Step 2: Mounting the General-Purpose File System
After a general-purpose file system is created, you need to mount it to ECSs so that they can share the file system.
- Log in to the ECS as user root. You can log in to an ECS using the console or a remote access tool (such as PuTTY).

- Install the NFS client.
- Check whether the NFS software package is installed in the system (CentOS is used in this example).
rpm -qa|grep nfs
If information similar to the following is displayed, the NFS software package has been installed and you can resolve the domain name. If no command output is displayed, install the package.libnfsidmap nfs-utils

- Install the package.
sudo yum -y install nfs-utils
The command requires that the ECS be connected to the Internet. Or, the installation will fail.
- Check whether the NFS software package is installed in the system (CentOS is used in this example).
- Check whether the domain name of the general-purpose file system can be resolved.
nslookup <domain-name-of-the-general-purpose-file-system>
- Obtain the domain name of a general-purpose file system from its shared path. For example, if the shared path is xxx:/sfs-name-001, xxx is the file system domain name, and sfs-name-001 is the file system name.
- If the nslookup command cannot be used, you can run yum install bind-utils to install the bind-utils software package.
- If the domain name can be resolved, mount the NFS file system to the root directory.
- If the domain name cannot be resolved, configure the DNS server IP address before mounting the file system. For details, see Configuring a DNS Server for Domain Name Resolution.
- Mount the NFS file system to the root directory.
mkdir <local-path> mount -t nfs -o vers=3,timeo=600,noresvport,nolock,tcp <shared-path> <local-path>
If any other resources, such as a disk, have been mounted on the desired local path, create a new path. (NFS clients do not reject repeated mounts. If there are repeated mounts, information of the last successful mount is displayed.)
Parameter
Description
vers
Version of the general-purpose file system. Only NFSv3 is supported currently, so the value is fixed at 3.
timeo
Waiting time before the NFS client retransmits a request. The unit is 0.1 seconds. 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 specify noresvport, which ensures that your file system remains uninterrupted after a network reconnection or recovery.
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 client. It is invalid for applications on any other clients.
tcp
Protocol used by the NFS client to send requests to the server. You can use either UDP or TCP.
General-Purpose File System does not support UDP. Therefore, you need to set proto to tcp for general-purpose file systems.
<shared-path>
The format is <file-system-domain-name>:/<file-system-name>, for example, example.com:/sfs-name-001.
<local-path>
A local path on the ECS used to mount the general-purpose file system, for example, /local_path.
- View the mounted general-purpose file system.
mount -l
If the command output contains the following information, the file system has been mounted:<shared-path> on </local-path> type nfs (rw,vers=3,timeo=600,nolock,addr=)
- (Optional) Modify the fstab file to configure file system auto mount upon system startup.
After a client ECS is restarted, it loses the file system mount information. You can configure auto mount in the fstab file to ensure that the ECS automatically mounts the file system when it restarts.
- Open the /etc/fstab file.
vi /etc/fstab
At the end of the file, add information about the general-purpose file system, for example:<shared-path> </local-path> nfs vers=3,timeo=600,noresvport,nolock,tcp 0 0
Replace <shared-path> and </local-path> with actual values. You can obtain the shared path from the Mount Point column of the file system. The fields are described as follows.

Parameter
Description
<shared-path>
The address or location of the general-purpose file system. Set it to the shared path used in the mount command for mounting the NFS file system to the root directory.
/local_path
A directory created on the ECS for mounting the general-purpose file system. Set it to the local path used in the mount command for mounting the NFS file system to the root directory.
nfs
The file system or partition mount type.
vers=3,timeo=600,noresvport,nolock,tcp
Use commas (,) to separate multiple options.
- vers: The general-purpose file system version. Value 3 indicates NFSv3.
- timeo: The waiting time before the NFS client retransmits a request. The unit is 0.1 seconds. 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 specify noresvport, which ensures that your file system remains uninterrupted after a network reconnection or recovery.
- 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 client. It is invalid for applications on any other clients.
- tcp: The TCP transmission protocol.
0
- An integer greater than zero means that dump backup is used. A general-purpose file system with a smaller integer is dumped earlier than one with a larger integer.
- 0 means not to back up the general-purpose file system.
0
- This field is set to 1 for the root directory by default. The values for other directories start from 2. A general-purpose file system with a smaller integer is checked earlier than one with a larger integer.
- 0 means not to check the general-purpose file system.
For optimal system performance, configure file system information based on the mount example provided. If needed, you can customize certain mount options. Note that the customization may affect system performance.
- Press Esc, enter :wq, and press Enter to save and exit.
- (Optional) View the content of the /etc/fstab file after the update.
cat /etc/fstab
Step 3: Using the General-Purpose File System
After the file system is mounted, you can use it on the ECS as if using an ordinary directory, for example, read data from or write data to the file system.
- Remotely connect to the ECS and run the following commands to write data to the general-purpose file system:
# /mnt/sfs is the local mount point (local path). mkdir /mnt/sfs/dir1 touch /mnt/sfs/file1 echo 'hello sfs' > /mnt/sfs/file2
- Remotely connect to the ECS and run the following commands to read data from the general-purpose file system:
ls /mnt/sfs
If information similar to the following is displayed, the general-purpose file system can be accessed using NFS.

Related Information
After creating and mounting a general-purpose file system, you can use the following functions as needed:
- Configuring a Lifecycle Rule: To reduce storage costs, you can configure lifecycle rules to convert data in the general-purpose file system to infrequent access storage after a certain period.
- Managing General-Purpose File System Limits: General-purpose file systems support limits management. You can configure a capacity limit and the maximum number of files allowed for each general-purpose file system. This helps you properly allocate and manage resources.
What is your overall rating for this page?
Thank 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