This topic describes how to create a file system and mount the file system on a Linux Elastic Compute Service (ECS) instance.
- 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 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
- Log on to the NAS console.
- Choose Create File System. and click
- 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.
- 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.
- 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
- Log on to the NAS console.
- Choose .
- Find the target file system and choose .
- 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.
- 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.
- Log on to the ECS console.
- 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
- If CentOS, RHEL, or Aliyun Linux is running on the ECS instance, use the following command to install the NFS agent.
- 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
- Log on to the ECS console.
- 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.
Separate multiple mount options with commas (,). The following table lists the mount options.
- 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.
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.
- Run the
mount -lcommand to view the mount result.
The following figure shows an example of a successful mount.
- 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.
Troubleshoot common errors
If you fail to mount a file system, troubleshoot the issue. For more information, see Troubleshoot and fix mount issues.