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.
When you log on to the NAS console for the first time, follow the instructions on the page to activate NAS.
- NAS is authorized to access cloud resources.
- If you are a first-time user of an NAS General-purpose file system, follow these steps to complete the authorization. On the Overview page, click Authorization Management in the Common Entrance section.
- Click Authorize next to the Default NAS Authorization section.
- Click Authorize to assign the AliyunNASDefaultRole role to NAS.
- ECS instances are available in the region where you want to create a file system. For more information, see Create an ECS instance.
- If you want to create a mount target of the VPC type, you must create a VPC in the same region where the linked file system resides. Then, you attach the ECS instance that hosts the file system to the VPC. For more information, see Create a VPC and VSwitch.
Step 1: Create a file system
- Log on to the NAS console.
- Choose Create File System. and click
- In the NAS General-purpose section, click Pay-as-you-go.
The topic takes a pay-as-you-go file system as an example. If you want to attach a storage plan, click Purchase Storage Plan. A storage plan is a billing method that is more cost effective compared to a pay-as-you-go billing method. For more information, see Purchase a storage plan.
- In the Create File System dialog box, configure the required settings.
Parameter Description Region The region.Note If an ECS instance and file system reside in different regions, the ECS instance cannot access the file system.
You can create a maximum of 20 file systems in a region by using an Alibaba Cloud account.
The supported storage types and protocol types of a file system change based on the region. For more information, see Storage types and protocol types supported by NAS in different regions.
Zone The zone. Each region has many isolated locations known as zones. The power supply and network of each zone are independent. In the same region but different zones, an Elastic Compute Service (ECS) instance can access a file system.
Select a zone from the drop-down list. We recommend that the zone you select is the same as the zone where the ECS instance resides. This eliminates extra latency due to cross-zone communication between the file system and the ECS instance.
Protocol Type The protocol type. Select NFS (including NFSv3 and NFSv4).
The Network File System (NFS) protocol is applicable to file sharing among Linux ECS instances.
Storage Type The storage type. Valid values: SSD performance-type and Capacity-type.
The maximum size of a NAS Performance file system is 1 PB. The maximum size of a NAS Capacity file system is 10 PB. The pay-as-you-go billing method is adopted.
Encryption You can use keys that are hosted by Key Management Service (KMS) to encrypt data at rest on a file system. Data is automatically decrypted when you access encrypted data. For more information, see Data encryption. Network Type The network type. Both the VPC and classic network are supported.This parameter specifies the network type of the mount targets for NAS file systems. You can attach up to two mount targets to each file system. For more information about how to create a mount target, see Add a mount target.Note
- You can create a mount target of the classic network type in a region that resides only in China.
- You can attach a mount target of the classic network type only to an ECS instance.
VPC The VPC. If no VPC exists, create a VPC in the VPC console.Note The VPC that you select must be the same as that of the ECS instance on which you mount a file system. An ECS instance and a file system may reside in different VPCs. To enable communication between the ECS instance and the file system, you can use Cloud Enterprise Network (CEN). For more information, see Enable a cross-VPC mount for a file system. VSwitch The VSwitch.
- 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 1: Install an NFS client
Before you mount an NFS file system on a Linux ECS instance, you must install an NFS client.
- Log on to the ECS console.
- Use the following command to install the NFS client.
- If CentOS, RHEL, or Aliyun Linux is running on the ECS instance, use the following
command to install the NFS client.
sudo yum install nfs-utils
- If Ubuntu or Debian is running on the ECS instance, use the following commands to
install the NFS client.
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 client.
- 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 3: Mount a file system
- Log on to the ECS console.
- Mount an NFS file system.
Use the following command to mount the NF file system. In the command, replace file-system-id.region.nas.aliyuncs.com:/ /mnt with a value that is specific to your environment.
The following table describes the parameters used in the mounting command.
- To mount an NFSv4 file system, use the following command.
sudo mount -t nfs -o vers=4,minorversion=0,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport file-system-id.region.nas.aliyuncs.com:/ /mnt
If you fail to mount the file system, use the following command.
sudo mount -t nfs4 -o rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport file-system-id.region.nas.aliyuncs.com:/ /mnt
- To mount an NFSv3 file system, use the following command.
sudo mount -t nfs -o vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport file-system-id.region.nas.aliyuncs.com:/ /mnt
Parameter Description file-system-id.region.nas.aliyuncs.com:/ /mnt Specifies the mount target of the NAS file system, the forward slash (/) following the mount target specifies the root directory of the NAS file system, and /mnt specifies a local directory that resides on the Linux ECS instance. You must replace the example values based on your business requirements.
- The mount target, for example, file-system-id.region.nas.aliyuncs.com. To obtain information about a mount target, follow these steps. Log on to the NAS console, find the target system, click Manage next to the file system to go to the Details page. The Details page shows information about the mount target.
- The directory of the NAS file system: specifies the root directory (/) or a subdirectory (/share). If a subdirectory is specified, ensure that the subdirectory exists.
- The local directory on which you want to mount a file system: specifies the root directory (/) or a subdirectory (/mnt) of a system such as Linux. If a subdirectory is specified, ensure that the subdirectory exists.
vers The version of the file system. NFSv3 and NFSv4 are applicable. Mount parameters
Multiple mount parameters are available when you mount a file system. For more information, see the following table.Notice When you set parameters, take note of the following items.
Separate multiple mount parameters with commas (,). The following table describes the mount parameters.
- To avoid a decrease in performance, we recommend that you specify the maximum value (1048576) for both the rsize parameter and the wsize parameter.
- If you need to modify the timeo parameter, we recommend that you specify a minimum of 150 for the parameter. The timeo parameter 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 parameter. Use caution with the soft parameter.
- We recommend that you use the default values for other mount parameters. For example, a decrease in performance may occur due to changes in some mount parameters. These mount parameters include the size of the read or write buffer or the use of attribute caching.
Parameter Description rsize Specifies the maximum number of bytes in each read request that the NFS client can receive. Recommended value: 1048576 wsize Specifies the maximum number of bytes in each write request that the NFS client 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 parameter. timeo Specifies the time in deciseconds that the NFS client waits before it retries an NFS request. Recommended value: 60 seconds retrans Specifies the number of times the NFS client retries a request. Recommended value: 2 noresvport Specifies that the NFS client uses a different TCP source port for a new network connection to ensure data integrity. We recommend that you use the noresvport parameter.
- To mount an NFSv4 file system, use the following command.
- Use the
mount -lcommand to view the mount result.
The following figure shows an example of a successful mount.
After a file system is mounted, you can use the
df -hcommand to view the size of the file system.
- 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 a mount operation fails, you can troubleshoot the issue. For more information, see Troubleshoot and fix mount issues.