Updated on 2025-12-10 GMT+08:00

Mounting a General-Purpose File System to Linux ECSs

After creating a general-purpose file system, you need to mount it to cloud servers so that they can share the file system. This section describes how to mount a file system to ECSs.

  • The operations of mounting a file system to BMSs and containers (created on CCE) are the same as those of ECSs. To use file systems for CCE, see Storage > Storage Overview or Storage > SFS and then complete the deployment on the CCE console.
  • The mount operation may vary depending on the server OS. Perform operations based on your server OS.
  • General-purpose file systems cannot be mounted to 32-bit Linux servers.

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 modified 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 of the file system server. Each time a root directory attribute is queried, the current time of the server is returned.

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 general-purpose file system and obtained its mount point from the file system list.
  • At least one ECS that is in the same VPC as the general-purpose file system is available.
  • You have configured the IP address of the DNS server on the ECSs. The DNS server is used to resolve the domain name of the general-purpose file system. For details, see Binding an EIP.
  • Before mounting a general-purpose file system to a LinuxECS, you need to configure a VPC endpoint. For details, see Configuring a VPC Endpoint.

Mounting a General-Purpose File System

  1. Log in to the ECS console.
  2. Log in the ECS as user root. You can log in using the console or a remote access tool (such as PuTTY).

  3. Install the NFS client.

    1. Check whether the NFS software package is installed.
      • On CentOS, Red Hat, Oracle Enterprise Linux, SUSE, EulerOS, Fedora, or openSUSE, run the following command:

        rpm -qa|grep nfs

      • On Debian or Ubuntu, run the following command:

        dpkg -l nfs-common

      If a command output similar to the following is displayed, the NFS software package has been installed and you can go to 4. If information similar to the following is not displayed, go to 3.b.
      • 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
    2. Install the NFS software package.

      The following commands require that ECSs be connected to the Internet. Or, the installation will fail.

      • On CentOS, Red Hat, EulerOS, Fedora, or Oracle Enterprise Linux, run the following command:
        sudo yum -y install nfs-utils
      • On Debian or Ubuntu, run the following command:
        sudo apt-get install nfs-common
      • On SUSE or openSUSE, run the following command:
        zypper install nfs-client

  4. Check whether the domain name in the mount point 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 mount point. For example, if the mount point of a general-purpose file system 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 resolution succeeds, proceed with the following steps.
    • If the domain name cannot be resolved, configure the DNS server IP address before mounting the general-purpose file system. For details, see Configuring a DNS Server for Domain Name Resolution.

  5. Mount the NFS file system.

    • To mount the file system root directory, run the following commands:
    mkdir <local-path>
    mount -t nfs -o vers=3,timeo=600,noresvport,nolock,tcp <mount-point> <local-path>
    • To mount a file system subdirectory, run the following commands:
    mkdir <local-path>/<subdirectory>
    mount -t nfs -o vers=3,timeo=600,noresvport,nolock,tcp <file-system-domain-name>:/<subdirectory> <local-path>
    • You can obtain the file system domain name from its mount point in the file system list. For example, if the mount point of a general-purpose file system is xxx:/sfs-name-001, xxx is the file system domain name, and sfs-name-001 is the file system name.
    • If any other resources, such as a disk, have been mounted on the desired 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.)
    • A file system can only be mounted to the ECSs that are in the same VPC as the file system.
    Table 1 describes the variables in the mount command.
    Table 1 Parameter description

    Parameter

    Description

    <local-path>

    A local directory on the ECS used to mount the file system, for example, /local_path.

    <mount-point>

    The format of a general-purpose file system is <file-system-domain-name>:/<file-system-name>, for example, example.com:/xxx.

    NOTE:
    • Variable x is a digit or letter.
    • If the mount point is too long to display completely, you can adjust the column width.
    • Hover over the mount point to view the full mount command.

    vers

    The file system version. Only NFSv3 is supported currently, so the value is fixed at 3.

    timeo

    The 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 specify noresvport, 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 client. If nolock is specified, the lock is valid only for applications on the same client. It is invalid for applications on any other clients. nolock is recommended. If this parameter is not specified, lock is used. Then, other clients cannot write data to the file system.

    General-purpose file systems 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, specify nolock to avoid such issues.

    tcp/udp

    The protocol used by NFS clients 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.

    Figure 1 Mount Point

    When mounting the file system, you can add performance optimization options described in Table 2. Use commas (,) to separate them. For 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 Performance optimization options

    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 integer that is a multiple of 1024. If the entered value is smaller than 1024, the value is automatically set to 4096. If the entered value is greater than 1048576, the value is automatically set to 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 integer that is a multiple of 1024. If the entered value is smaller than 1024, the value is automatically set to 4096. If the entered value is greater than 1048576, the value is automatically set to 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.

    hard is used by default.

    retrans

    The number of retransmission times before the client returns an error. The recommended value is 1.

    tcp/udp

    If mountproto is not specified, the client will mount the file system using UDP first. If the UDP network cannot be connected, the client will mount the file system using TCP after freezing for several seconds.

    The security group of the file system does not allow inbound traffic over UDP ports, so you need to specify mountproto=tcp.

    ro/rw

    • ro indicates that the file system is mounted as read-only.
    • rw indicates that the file system is mounted as read/write.

    rw is used by default. If neither ro nor rw is specified, the file system will be mounted as read/write.

    sync/async

    sync indicates that data is written to the server immediately. 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 recommendations provided.

  6. View the mounted general-purpose file system.

    mount -l
    If the command output contains the following information, the file system has been mounted. You can access the file system from the ECS to read or write data.
    <mount-point> on </local-path> type nfs (rw,vers=3,timeo=600,nolock,addr=)

    The maximum size of a file that can be written to a general-purpose file system is 240 TB.

  7. (Optional) Configure 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.

    1. Open the /etc/fstab file.
    vi /etc/fstab
    At the end of the file, add the file system information, for example:
    <mount-point> </local-path> nfs vers=3,timeo=600,nolock,tcp 0 0

    Replace <mount-point> and </local-path> with actual values. You can obtain the mount point from the file system list. Each record in the /etc/fstab file represents a mount. Each record has six fields, as described in Table 3.

    Table 3 Mount fields

    Field

    Description

    <mount-point>

    The address or location of the general-purpose file system you are mounting. Set it to the mount point in the mount command in 5.

    /local_path

    A directory on the ECS used to mount the file system. Set it to the local path in the mount command in 5.

    nfs

    The file system or partition mount type. Set it to nfs.

    vers=3,timeo=600,nolock,tcp

    The mount options. Use commas (,) to separate multiple options.

    • vers: The file system version. Value 3 indicates NFSv3.
    • timeo: The waiting time before the NFS client retransmits a request. The unit is 0.1 second. The recommended value is 600.
    • nolock: Whether to use the NLM protocol to lock files on the client. If nolock is specified, the lock is valid only for applications on the same client. It is invalid for applications on any other clients. nolock is recommended. If this parameter is not specified, lock is used. Then, other clients cannot write data to the file system.
    • tcp: The TCP transmission protocol.

    0

    Choose whether to use dump to back up the file system.

    • 0: Dump backup is not used.
    • An integer greater than zero means that dump backup is used. A file system with a smaller integer is dumped earlier than one with a larger integer.

    0

    Choose whether to use fsck to check file systems when the ECS is starting and specify the sequence for checking file systems.

    • 0: File systems are not checked.
    • By default, this field is set to 1 for the root directory. The values for other directories start from 2, and one with a smaller integer is checked earlier than one with a larger integer.

    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.

    1. Press Esc, enter :wq, and press Enter to save and exit.
    1. (Optional) View the content of the /etc/fstab file after the update.
    cat /etc/fstab
    If auto mount fails due to a network issue, add the sleep option and a time in front of the mount command in the rc.local file, and mount the file system after the NFS service is started.
    sleep 10s && sudo mount -t nfs -o vers=3,timeo=600,noresvport,nolock,tcp <mount-point>/<local-path>

FAQs

SFS Mount