You can manually attach a pay-as-you-go disk as a data disk to an Elastic Compute Service (ECS) instance within the same zone to enhance the instance storage capacity and accommodate new business needs. Attaching a disk that already contains data, such as a disk that is created from a snapshot, does not result in data loss.
Limits
Up to 64 data disks can be attached to an ECS instance. The number of disks that can be attached to an ECS instance varies based on the instance type. To query the maximum number of data disks supported by each instance type, call the DescribeInstanceTypes operation and query the DiskQuantity parameter in the response.
Different instance families support various disk categories. For more information, see Overview of instance families.
By default, a disk is attachable to only one ECS instance. To attach a disk to multiple ECS instances, you must enable the multi-attach feature. The feature is available for specific disk categories and instance types. For more information, see Multi-attach for cloud disks.
Local disks are automatically created with the instance and do not require separate attachment.
Prerequisites
The disk that you want to attach to an instance is in the Available (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 a disk is in the Running (Running) or Stopped (Stopped) state, not in the Locked (Locked) state.
Your Alibaba Cloud account do not have overdue payments.
Procedure
This section describes how to attach a data disk to an ECS instance on the instance details page.
You can also go to the cloud disk list page, find a disk that you want to attach to an instance and select
in the Actions column corresponding to the disk to attach the disk to the 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 instance to which you want to attach a disk and click the instance ID.
Click the Block Storage tab. Above the disk list, click Attach Cloud Disk .
Attach the disk to the destination instance and select a release mode.
Parameter
Description
Disk
Select a disk that you want to attach to the ECS instance.
Release Cloud Disk with Instance
Select this option if you want to release the disk when the ECS instance is released.
Clear this option if you want to retain the disk when the ECS instance is released.
ImportantIf a system disk was detached from another instance and attached as data disk to the instance that you select, the Release Disk with Instance feature takes effect on the source ECS instance from which the system disk is detached, not on the current instance.
Delete Automatic Snapshots While Releasing Disk
Select this option if you want to delete the automatic snapshots created from the disk when the disk is released.
ImportantWe recommend that you clear this option to retain backup data on the disk.
Click Next.
In the Attach Cloud Disk dialog box, click Initialize Now in the Initialization Method section. Follow the on-screen instructions to initialize the disk or to mount a file system on the disk by using Cloud Assistant or referring to the relevant documentation.
For newly created empty data disks that have no partitions or file systems, you must create partitions and file systems and then mount these file systems.
For disks created from snapshots or data disks detached from other instances that have no mounted file systems, you only need to mount the file systems. Mounting file systems dos not result in data loss.
Create partitions and mount file systems
Use Cloud Assistant on a Linux instance
Specify the partition size and mount point.
NoteYou can click Create Partition to add multiple partitions to the disk based on your business requirements. Up to five partitions can be added to each disk.
Partition size: The size of a single partition and the total size of all partitions cannot exceed the total capacity of the disk.
Note1 MiB or 2 MiB of storage space must be reserved for the partition table and sector alignment. The partitioning feature automatically reduces the size of the last partition to reserve space. Therefore, the actual size of the partitions may be slightly less than specified size, and the total available capacity may be slightly less than the total capacity of the disk.
File system type: Only Ext4 file systems are supported. The default partition style is GPT.
Mount point: The mount point must start with a forward slash (/) and can contain letters and digits. Example: /mnt. You can specify an existing directory that does not contain data or a new directory as a mount point. The mount point cannot be duplicated.
ImportantIf the destination directory contains data, mounting partitions to the directory overwrites system files in the directory, which may cause data loss and affect business operations.
Confirm and select the risk statement and then click OK.
NoteIf you accidentally close the page, you can use Cloud Assistant to create partitions and file systems again by referring to Initialize a data disk whose size does not exceed 2 TiB on a Linux instance.
When Normal appears in the Current Status column in the initialization task list, the disk is initialized.
(Optional) Configure the system to automatically mount the partitions on instance startup. For details, 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, perform the following operations:
For Linux instances: Initialize a data disk whose size does not exceed 2 TiB on a Linux instance.
For Windows instances: Initialize a data disk on a Windows instance.
Only mount file systems
Use Cloud Assistant on a Linux instance
In the Partition and Mount Settings section, enter a mount point in the Mount Point column and click Manually Mount to mount the file system.
NoteYou can specify an existing directory that does not contain data or another directory as a mount point. The mount points cannot be duplicated.
NoteIf you accidentally close the page, you can use Cloud Assistant to mount the file system again. For more information, see Initialize a data disk whose size does not exceed 2 TiB on a Linux instance.
(Conditionally required) If a disk created from a snapshot is attached to the original ECS instance to which the source disk of the snapshot is attached, the UUID of the new disk conflicts with the UUID of the source disk. You must change the UUID of the new disk. For more information, see Change the UUID of a disk.
(Conditionally required) If a disk created from a snapshot is larger than the source disk, you must resize the partitions and file systems before using the disk in the operating system.
For Linux instances, see Extend the partitions and file systems of disks on a Linux instance.
For Windows instances, see Extend the partitions and file systems of disks on a Windows instance.
(Optional) Configure the disk partitions to automatically mount on instance startup. For details, 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, perform the following steps:
(Conditionally required) If the cloud disk created from a snapshot is attached to the Linux ECS instance to which the source disk of the snapshot is attached, the UUID of the new cloud disk conflicts with the UUID of the source disk. You must change the UUID of the new cloud 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
.
Sample
mount
command: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 of 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.