You can attach a pay-as-you-go disk as a data disk to an Elastic Compute Service (ECS) instance that resides in the same zone as the disk to increase storage capacity and meet your business requirements. If you attach a disk that contains data, such as a disk created from a snapshot, as a data disk to an ECS instance, the operation does not cause data loss.
Limits
You can attach up to 64 data disks to an ECS instance. The maximum number of disks that can be attached to an ECS instance varies based on the instance type. To query the maximum number of disks that you can attach to an ECS instance of a specific instance type, call the DescribeInstanceTypes operation and check the DiskQuantity parameter in the response.
Different instance families support different disk categories. For more information, see Overview of instance families.
By default, you can attach a disk to only one ECS instance. If you want to attach a disk to multiple ECS instances, enable the multi-attach feature for the disk. Limits on disk categories and instances apply to the multi-attach feature. For more information, see Multi-attach for cloud disks.
Prerequisites
The disk that you want to attach is in the Unattached (Available) state.
The disk and the ECS instance to which you want to attach the disk are in the same zone.
The ECS instance to which you want to attach the disk is in the Running (Running) or Stopped (Stopped) state, instead of the Locked (Locked) state.
Your Alibaba Cloud account does not have overdue payments.
Procedure
This section describes how to attach a data disk on the Instance Details page.
You can also go to the Cloud Disk tab on the Block Storage (Disks) page and choose
in the Actions column to attach a disk to an ECS instance.Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
Find the ECS instance to which you want to attach a disk and click the ID of the instance.
Click the Block Storage tab and then click Attach Cloud Disk above the disk list.
Select a disk and a release mode. The following table describes the parameters.
Parameter
Description
Disk
Select the disk that you want to attach to the ECS instance.
Release Cloud Disk with Instance
If you want to release the disk when the ECS instance is released, select this option.
If you want to retain the disk when the ECS instance is released, clear this option.
ImportantIf the disk that you want to attach is a system disk detached from a different ECS instance, the ECS instance that is specified by the Release Cloud Disk with Instance parameter refers to the ECS instance from which the disk was detached rather than the current ECS instance.
Delete Automatic Snapshots While Releasing Disk
If you want to delete the automatic snapshots of the disk when the disk is released, select this option.
ImportantTo retain backup data, we recommend that you clear this option.
Click Next.
In the Initialization Method section of the Attach Cloud Disk dialog box, click Initialize Now. Follow the on-screen instructions to initialize the disk or mount file systems on the disk by using Cloud Assistant or by referring to the ECS documentation.
If the disk is a new empty disk (a disk that is not partitioned and on which no file systems are mounted), you must create partitions and mount file systems on the disk.
If the disk is created from a snapshot or is detached from a different ECS instance but no file systems are mounted on the disk, you need to only mount file systems on the disk. Mounting file systems does not cause data loss.
Create partitions and mount file systems
Use Cloud Assistant
Create partitions and configure mount points.
NoteYou can click Create Partition to create multiple partitions on the disk based on your business requirements. You can create up to five partitions on a single disk.
Size: The size of each partition or the total size of all partitions cannot exceed the disk size.
NoteYou must reserve 1 MiB or 2 MiB of storage space for the partition table and sector alignment for partitions. The partitioning feature reduces the size of the last partition to reserve the required storage space. As a result, the actual partition size may be slightly smaller than the specified partition size. The total size of partitions may also be smaller than the disk size.
File System Type: The disk supports only Ext4 file systems, and the default partition style is GUID Partition Table (GPT).
Mount Point: The mount point must start with a forward slash (/) and can contain letters and digits. Example: /mnt. Enter an existing directory or create a directory as the mount point. Mount points must be unique.
Confirm and select the risk statement and then click OK.
ImportantIf you click Close, you can only run commands to create partitions and file systems.
If the value of Status changes to Normal for the disk in the Partition Disk and Mount File Systems dialog box, the disk is initialized.
(Optional) Configure the partitions on the disk to automatically mount on instance startup. For more information, see Step 4: Configure the disk partition to automatically mount on instance startup.
Refer to documentation (CLI)
If you cannot use Cloud Assistant to initialize the disk, you can run commands to initialize the disk.
Linux instance
For information about how to initialize a disk that is up to 2 TiB in size, see Initialize a data disk whose size does not exceed 2 TiB on a Linux instance.
For information about how to initialize a disk that exceeds 2 TiB in size, see the Initialize a data disk whose size exceeds 2 TiB on a Linux instance section of the "Initialize a data disk whose size exceeds 2 TiB" topic.
Windows instance
For information about how to initialize a disk that is up to 2 TiB in size, see Initialize a data disk whose size does not exceed 2 TiB on a Windows instance.
For information about how to initialize a disk that exceeds 2 TiB in size, see the Initialize a data disk that is larger than 2 TiB on a Windows instance section of the "Initialize a data disk whose size exceeds 2 TiB" topic.
Only mount file systems
Use Cloud Assistant (only for Linux ECS instances)
In the Partition Disk and Mount File Systems dialog box, configure the Mount Point parameter and click Manually Mount to mount file systems.
NoteEnter an existing directory or create a directory as the mount point. Mount points must be unique.
(Optional) Configure the partitions on the disk to automatically mount on instance startup. For more information, see Step 4: Configure the disk partition to automatically mount on instance startup.
Refer to documentation (CLI)
If you cannot use Cloud Assistant to mount file systems on the disk, you can perform the following steps to mount file systems on the disk.
(Conditionally required) If you create a disk from a snapshot and attach the created disk to the ECS Linux instance to which the source disk of the snapshot is attached, the UUIDs of the new disk and source disk conflict. You must change the UUID of the new disk. For more information, see Change the UUID of a disk.
Mount
partitions to the cloud disk or bring the disk online.Linux instance
Connect to the ECS instance to which the cloud disk is attached and run the following command to
mount
a partition to the disk:sudo mount <Disk partition name> <Mount point>
<Disk partition name>
: Specify the name of the partition. Run thesudo fdisk -lu
command to query the partition name. Example:/dev/vdc
.<Mount point>
: Specify an existing directory or run thesudo mkdir -p <New directory>
command to create a new directory as the mount point. Example:sudo mkdir -p /data
.The example of
mount
:sudo mount /dev/vdc /data
.
Write the new partition information to the
/etc/fstab
file. This way, the partition is automatically mounted on system startup.For more information, see the Step 4: Configure the disk partition to automatically mount on instance startup section in the "Initialize a data disk whose size does not exceed 2 TiB on a Linux instance" topic.
Windows instance
Connect to the ECS instance to which the cloud disk is attached, click the icon, and then select Disk Management.
Find the cloud disk that you want to manage, right-click a blank area, and select Online.