This topic describes how to create a file system and mount the file system on a Linux Elastic Compute Service (ECS) instance.

Prerequisites

  • An Alibaba Cloud account is created and passes the real-name verification. For more information, see Create an Alibaba Cloud account.
    Note You can use a RAM user to perform fine-grained access control. For more information, see Create a custom policy.
  • Apsara File Storage NAS is activated.

    The first time you log on to the NAS console, follow the instructions on the page to activate NAS.

  • Apsara File Storage NAS is authorized to access cloud resources.

    If you are using Extreme NAS for the first time, click Go to authorization in the Overview > Common Entrance > Authorization Management > Express and CPFS Default Service Authorization section to create and assign the AliyunNASMangeENIRole role to NAS.

  • A virtual private cloud (VPC) is available in the region where you want to create a file system. For more information about how to create a VPC and VSwitch, see Create an IPv4 VPC.
  • An ECS instance is available in the region where you want to create a file system on Alibaba Cloud. The ECS instance is added to the VPC. For more information, see Create an ECS instance.

Step 1: Create a file system

  1. Log on to the NAS console.
  2. Choose File System > File System List and click Create File System.
  3. In the Extreme NAS section, click Pay-as-you-go.
    In this example, the pay-as-you-go billing method is used. If you want to create a subscription file system, click Subscription. The subscription billing method is more cost effective than the pay-as-you-go billing method.
  4. On the buy page, set the parameters.
    Parameter Description
    Region Select the region where you want to create a file system.
    Note If an ECS instance and a file system reside in different regions, the ECS instance cannot access the file system.
    Zone Each region has multiple isolated locations that are known as zones. The power supply and network of each zone are independent. An ECS instance can access a file system in the same region but different zones.

    Select a zone. We recommend that you select the zone where the ECS instance resides. This eliminates extra latency for cross-zone communication between the file system and the ECS instance.

    Protocol Type Select NFS.
    Note Only NFSv3 is applicable to Extreme NAS file systems.
    Type Valid values: Standard and Advanced.
    Capacity Select the capacity based on your business requirements.
    Throughput Select the throughput based on your business requirements.
  5. Click Buy Now and follow the instructions to complete the payment.
    Note After you create the file system, the default permission group is attached to the file system. For more information about how to change a permission group, see Modify the permission group of a mount target.

Step 2: Create a mount target

Before you mount a file system on an ECS instance, create a mount target for the file system. Extreme NAS file systems support only mount targets of the VPC type. Perform the following steps to create a mount target.
Note You can create a maximum of one mount target for each file system.
  1. Log on to the NAS console.
  2. Choose File System > File System List.
  3. Find the target file system and choose More > Add Mount Target.
  4. On the Add Mount Target page, set the parameters.
    Parameter Description
    VPC Network Select a VPC. If no VPC is available, create a VPC in the VPC console.
    Note You must select the VPC where the ECS instance resides and select a VSwitch in the VPC. If you select another VPC, the ECS instance and the mount target reside in different VPCs. To enable communication between the ECS instance and the file system, you must use Cloud Enterprise Network (CEN) to connect the VPCs. For more information, see Enable a cross-VPC mount for a file system.
    Switch Select the VSwitch that resides in the VPC.
    Access Group Select a permission group based on your requirements.

    A permission group named VPC default permission group (all allowed) is generated for each Alibaba Cloud account. This permission group allows access from all IP addresses in the VPC to the file system through the mount target. For more information about how to create a permission group, see Manage permission groups.

  5. Click OK to create the mount target.

Step 2: Install an NFS agent

Before you mount an NFS file system on a Linux ECS instance, you must install an NFS agent.

  1. Log on to the ECS console.
  2. Use the following command to install the NFS agent.
    • If CentOS, RHEL, or Aliyun Linux is running on the ECS instance, use the following command to install the NFS agent.
      sudo yum install nfs-utils
    • If Ubuntu or Debian is running on the ECS instance, use the following commands to install the NFS agent.
      sudo apt-get update
      sudo apt-get install nfs-common
  3. Set the maximum number of concurrent NFS requests to 128. For more information, see How can I modify the maximum number of concurrent NFS requests?.

Step 4: Mount the NFS file system

  1. Log on to the ECS console.
  2. Run the following command to mount the NFS file system:
    sudo mount -t nfs -o vers=3,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport file-system-id.region.extreme.nas.aliyuncs.com:/share /mnt

    The following table lists the parameters that are used in the mount command.

    Parameter Description
    file-system-id.region.extreme.nas.aliyuncs.com:/share /mnt The command syntax is <Domain name of the mount target>:<Name of the shared directory><Path of the shared directory>. Replace the domain name, directory name, and directory path based on your business requirements.
    • The domain name of the mount target: The format is file-system-id.region.extreme.nas.aliyuncs.com. To view the ID and region of a file system, log on to the NAS console, find the target file system, and click Management. On the page that appears, you can view the ID and region of the file system.
    • The name of the shared directory: For an Extreme NAS file system, the directory must start with /share, for example, /share or /share/subdir.
    • The local directory on which you want to mount a file system: Specify the root directory (/) or a subdirectory (/mnt) of a system such as Linux. If a subdirectory is specified, make sure that the subdirectory exists.
    vers The protocol version of the file system is NFSv3.
    Mount options Multiple mount options are available when you mount a file system. The following table lists the mount options.
    Notice When you set options, take note of the following items.
    • To avoid a decrease in performance, we recommend that you specify the maximum value (1048576) for both the rsize mount option and the wsize mount option.
    • If you must modify the timeo mount option, we recommend that you specify a minimum of 150 for the mount option. The timeo mount option is measured in deciseconds (tenths of a second). For example, a value of 150 indicates 15 seconds.
    • To avoid data inconsistency, we recommend that you do not use the soft mount option. Use caution with the soft mount option.
    • We recommend that you use the default values for other mount options. For example, a decrease in performance may occur due to changes in some mount options. These mount options include the size of the read or write buffer or the use of attribute caching.
    Separate multiple mount options with commas (,). The following table lists the mount options.
    Option Description
    rsize Specifies the maximum number of bytes in each read request that the NFS agent can receive. Recommended value: 1048576.
    wsize Specifies the maximum number of bytes in each write request that the NFS agent can send. Recommended value: 1048576.
    hard Specifies that applications must stop accessing a file system when the file system is unavailable, and wait until the file system is available. We recommended that you use the hard mount option.
    timeo Specifies the time in deciseconds (tenths of a second) that the NFS agent waits before it retries an NFS request. Recommended value: 600, indicating 60 seconds.
    retrans Specifies the number of times the NFS agent retries a request. Recommended value: 2.
    noresvport Specifies that the NFS agent uses a different TCP source port for a new network connection to ensure data integrity. We recommend that you use the noresvport mount option.
  3. Run the mount -l command to view the mount result.

    The following figure shows an example of a successful mount.

    View the mount result
  4. After you mount an NAS file system on an ECS instance, you can access the file system from the ECS instance.

    You can access the file system in the same way you access a local directory. The following figure shows an example.

    Read and write operations

Troubleshoot common errors

If you fail to mount a file system, troubleshoot the issue. For more information, see Troubleshoot and fix mount issues.