• Scalable File Service

sfs
  1. Help Center
  2. Scalable File Service
  3. User Guide
  4. Getting Started
  5. Mounting an NFS File System to ECSs (Linux)

Mounting an NFS File System to ECSs (Linux)

After creating a file system, you need to mount the file system to ECSs so that ECSs can share the file system.

This section uses Linux as an example to describe how to mount an NFS file system.

Prerequisites

  • You have checked the type of operating system of the ECS. Different operating systems use different commands to install the NFS client.
  • You have created a file system and have obtained the shared path of the file system.
  • The ECSs to which a file system is mounted belong to the same VPC as the file system.
  • The IP addresses of the DNS server used to resolve the file system domain name have been configured on the ECSs.

Procedure

  1. Log in to the ECS as user root.
  2. Install the NFS client.

    1. Run the following command to check whether the NFS software package is installed.
      • On CentOS, Red Hat, Oracle Enterprise Linux, SUSE, Euler OS, Fedora, or OpenSUSE:

        rpm -qa|grep nfs

      • On Debian or Ubuntu:

        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 3. If no such command output is displayed, go to 2.b.
      • On CentOS, Red Hat, Euler OS, Fedora, or Oracle Enterprise Linux:
        libnfsidmap
        nfs-utils
      • On SUSE or OpenSUSE:
        nfsidmap
        nfs-client
      • On Debian or Ubuntu:
        nfs-common
    2. Run the following command to install the NFS software package.
      NOTE:

      The following commands require that ECSs be connected to the Internet. Otherwise, the installation will fail. Installing NFS clients requires enabling effective software repositories. Installing NFS clients will fail if software repositories are not enabled or the ECS does not have any software repository. If installing NFS clients fails, refer to Enabling or Adding a Software Repository.

      • On CentOS, Red Hat, Euler OS, Fedora, or Oracle Enterprise Linux:

        sudo yum -y install nfs-utils

      • On Debian or Ubuntu:

        sudo apt-get install nfs-common

      • On SUSE or OpenSUSE:

        zypper install nfs-client

  3. Run the following command to check whether the domain name in the file system shared path can be resolved.

    nslookup File system domain name

    NOTE:
    • A file system domain name is just a domain name. For example, sfs-nas1.xxxx.com. You can obtain a file system domain name from the shared path of a file system. In this step, you are not supposed to enter the entire shared path but only the domain name.
    • If the nslookup command cannot be used, install the bind-utils software package by running the yum install bind-utils command.
    • If yes, go to 4.
    • If no, configure the DNS server IP address and then mount the file system. For details, see Configuring DNS.

  4. Run the following command to create a local path for mounting the file system.

    mkdir Local path

  5. Run the following command to mount the file system to the ECSs. Currently, SFS supports mounting only file systems complying with NFSv3 to ECSs running Linux. Table 1 describes the variables.

    mount -t nfs -o vers=3,timeo=600,nolock Shared path Local path

    After an ECS that has mounted file systems restarts, it loses the file system mount information. You can configure automatic mount in the fstab file to ensure that an ECS automatically mounts file systems when it restarts. For details, see Mounting a File System Automatically.

    Table 1 Parameter description

    Parameter

    Description

    vers

    File system version. Currently, only NFSv3 is supported, so the value is fixed to 3.

    timeo

    The waiting time before the NFS client retransmits a request. The unit is 0.1 second. Recommended value: 600

    lock/nolock

    Whether to lock files on the server using the NLM protocol. If nolock is selected, the lock is valid for applications on one host. For applications on another host, the lock is invalid. Recommended value: nolock

    Shared path

    The format is File system domain name:/Path. For example, example.com:/share-xxx. See Figure 1.

    NOTE:

    x is a digit or letter.

    The shared path is too long to display completely. Expand the column to view the full shared path.

    Local path

    Local path on the ECS, used to mount the file system. For example, /local_path

    Figure 1 Shared Path

    For more mounting parameters for performance optimization during file system mounting, 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,noresvport,async,noatime,nodiratime Shared path Local path

    Table 2 Parameters for file system mounting

    Parameter

    Description

    rsize

    Maximum number of bytes that can be read from the server each time. The actual data is less than or equal to the value of this parameter. 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, the setting is performed after the negotiation between the server and the client.

    You are advised to set this parameter to the maximum value 1048576.

    wsize

    Maximum number of bytes that can be written to the server each time. The actual data is less than or equal to the value of this parameter. 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, the setting is performed after the negotiation between the server and the client.

    You are advised to set this parameter to the maximum value 1048576.

    soft/hard

    soft indicates that a file system is mounted in soft mounting mode. In this mode, if an NFS request times out, the client returns an error to the invoking program. hard indicates that a file system is mounted in hard connection mode. In this mode, if the 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. The default value is 3.

    resvport/noresvport

    Whether the confidential source port is used for server connection. By default, resvport indicates that the confidential port is used, and noresvport indicates that the confidential port is not used. The kernel version is 2.6.28 or later.

    You are advised to set this parameter to noresvport so that a new TCP port can be used when the network is reconnected. This ensures that the connection is not interrupted when the network recovers from a fault.

    sync/async

    sync indicates that data is written to the server immediately. async indicates that data is first written to the cache before being written to the server.

    Synchronous write requires that an NFS server returns a success message only after all data is written to the server, which brings long latency. The recommended value is async.

    noatime

    If you do not need to record the file access time, set this parameter. This prevents overheads caused by access time modification during frequent access.

    nodiratime

    If you do not need to record the directory access time, set this parameter. This prevents overheads caused by access time modification during frequent access.

    NOTE:

    You are advised to use the default values for the parameters without use recommendations.

  6. Run the following command to view the mounted file system.

    mount -l

    If the command output contains the following information, the mount is successful.
    example.com:/share-xxx on /local_path type nfs (rw,vers=3,timeo=600,nolock,addr=)

  7. After the file system is mounted successfully, you can access the file system on the ECSs to read or write data.

    NOTE:

    A maximum file of 240 TB can be written.

Follow-Up Operation

To cancel the mount, run the umount Local path command.

Before running the command, stop all read and write operations related to the file system and exit from the Local path directory. Otherwise, the unmounting fails.