Help Center> Scalable File Service> Getting Started> Mount a File System> Mounting an NFS File System to ECSs (Linux)
Updated on 2024-01-03 GMT+08:00

Mounting an NFS File System to ECSs (Linux)

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

CIFS file systems cannot be mounted to Linux servers.

An SFS Capacity-Oriented file system can use either NFS or CIFS. 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.

SFS 3.0 Capacity-Oriented file systems cannot be mounted to 32-bit Linux servers.

Prerequisites

  • You have checked the type of the operating system on each ECS. Different operating systems use different commands to install the NFS client.
  • You have created a file system and have obtained the mount point of the file system.
  • At least one ECS that belongs to the same VPC as the file system exists.
  • The IP address of the DNS server for resolving the domain names of the file systems has been configured on the ECS. SFS Turbo file systems do not require domain name resolution.

Procedure

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

    1. Install the NFS client.
      1. Run the following command to check whether the NFS software package is installed.
        • In CentOS, Red Hat, Oracle Enterprise Linux, SUSE, EulerOS, Fedora, or OpenSUSE:

          rpm -qa|grep nfs

        • In 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 b.
        • In CentOS, Red Hat, EulerOS, Fedora, or Oracle Enterprise Linux:
          libnfsidmap
          nfs-utils
        • In SUSE or OpenSUSE:
          nfsidmap
          nfs-client
        • In Debian or Ubuntu:
          nfs-common
      2. Run the following command to install the NFS software package.

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

        • In CentOS, Red Hat, EulerOS, Fedora, or Oracle Enterprise Linux:

          sudo yum -y install nfs-utils

        • In Debian or Ubuntu:

          sudo apt-get install nfs-common

        • In SUSE or OpenSUSE:

          zypper install nfs-client

  3. Run the following command to 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 is just a part of the mount point, for example, sfs-nas1.xxxx.com. You can obtain a file system domain name from the mount point of a file system. In this step, you are not supposed to enter the entire mount point 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 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.

  4. Run the following command to 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.)

  5. Run the following command to mount the file system to the ECS that belongs to the same VPC as the file system. Currently, the file system can be mounted 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 an SFS 3.0 Capacity-Oriented file system, run the following command: mount -t nfs -o vers=3,timeo=600,noresvport,nolock,proto=tcp Mount point Local path

    After an ECS where file systems have been mounted 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. 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 a network connection is re-established.

    It is strongly recommended you use the noresvport option, which ensures that your file system maintains uninterrupted availability after a network reconnection or recovery.

    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. The recommended value is nolock. If this parameter is not specified, lock is selected by default. In this case, other servers cannot write data to the file system.

    proto

    Protocol used by NFS clients to send requests to the server. Both UDP and TCP protocols can be used.

    UDP is currently not supported by SFS 3.0 Capacity-Oriented file systems. If you are using SFS 3.0, set this parameter to tcp, that is, proto=tcp.

    Mount point

    The format for an SFS Capacity-Oriented file system is File system domain name:/Path, for example, example.com:/share-xxx. The format for an SFS Turbo file system is File system IP address:/, for example, 192.168.0.0:/.

    The format for an SFS 3.0 Capacity-Oriented file system is File system domain name:/File system name, for example, example.com:/xxx.

    See Figure 1.

    NOTE:
    • x is a digit or letter.
    • If the mount point is too long to display completely, you can 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.

    Figure 1 Mount point

    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,tcp,noresvport,ro,async,noatime,nodiratime Mount point 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 mount 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 mount 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.

    tcp/udp

    Sets both the protocol used by NFS clients and that used for mounting to TCP or UDP.

    The UDP protocol is not used by the mount command. If the default command is used to mount an SFS Turbo file system, you may notice a delay of several seconds. To change the mounting command to TCP, set mountproto=tcp.

    To set the protocol used by NFS clients to TCP, set proto=tcp.

    To set both protocols at a time, simply set tcp or udp.

    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 a network connection is re-established.

    It is strongly recommended you use the noresvport option, which ensures that your file system maintains uninterrupted availability 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 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.

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

  6. Run the following command to 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=)

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

    If the mounting 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.