Updated on 2024-11-04 GMT+08:00

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.

In this section, ECSs are used as example servers. Operations on BMSs are the same as those on ECSs.

To use SFS Turbo file systems as storage backends for CCE, see Storage. Then complete the deployment on the CCE console.

SFS Turbo file systems cannot be mounted to Windows ECSs.

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 an SFS Turbo file system and obtained its shared path.
  • At least an ECS is available.

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

  1. Log in to the console using a cloud account.

    1. Log in to the console and select a region and a project.
    2. Choose Computing > Elastic Cloud Server to go to the ECS console.

  2. Log in to the ECS as user root.

    If you log in to the ECS as a non-root user, see Mounting a File System to a Linux as a Non-root User.

  3. Install the NFS client.

    1. 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 no such command output is displayed, go to 3.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
      2. Install the NFS software package.

        The following commands require that the 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. Create a local path for mounting the file system.

    mkdir Local path

    If any other resources, such as a disk, have been 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.)

  5. Mount the file system to the ECSs in the same VPC as the file system. You can mount the file system to Linux ECSs using NFSv3 only.

    Table 1 describes the mount parameters.

    To mount an SFS Turbo file system, run the following command: mount -t nfs -o vers=3,timeo=600,noresvport,nolock,tcp Shared path 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 Parameters required for mounting file systems

    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 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 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. Then, other servers cannot write data to the file system.

    Shared path

    For an SFS Turbo Standard-Enhanced, Standard, Performance-Enhanced, or Performance file system, the format is File system IP address:/, for example, 192.168.0.0:/.

    For an SFS Turbo 20 MB/s/TiB, 40 MB/s/TiB, 125 MB/s/TiB, 250 MB/s/TiB, 500 MB/s/TiB, 1,000 MB/s/TiB, or HPC cache file system, the format is File System domain name:/, for example, xxx.sfsturbo.internal:/.

    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. A command example is provided as follows:

    mount -t nfs -o vers=3,timeo=600,nolock,rsize=1048576,wsize=1048576,hard,retrans=3,noresvport,ro,async,noatime,nodiratime Shared path 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

    soft indicates soft mounts. With soft specified, if an NFS request times out, the client returns an error to the calling program. 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. The recommended value is 1.

    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 specify noresvport, which ensures that your file system remains uninterrupted after a network reconnection or recovery.

    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.

    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.

  6. View the mounted 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=)

  7. Check that you can access the file system on the ECSs to read or write data.

    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.