All Products
Search
Document Center

Elastic Compute Service:Attach a data disk

Last Updated:Apr 28, 2025

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 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 or Stopped state, not in the 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.

Note

You can also go to the cloud disk list page, find a disk that you want to attach to an instance and select Attach in the Actions column corresponding to the disk to attach the disk to the ECS instance.

  1. Go to ECS console - Instance.

  2. In the top navigation bar, select the region and resource group of the resource that you want to manage. 地域

  3. Find the instance to which you want to attach a disk and click the instance ID.

  4. Click the Block Storage tab. Above the disk list, click Attach Cloud Disk .

    截屏2024-12-25 09

  5. 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.

    Important

    If 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.

    Important

    We recommend that you clear this option to retain backup data on the disk.

  6. Click Next.

  7. 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.

    image

    New data disk that does not contain data

    If the data disk is a new empty disk that is not partitioned and on which no file systems are mounted, create partitions and file systems and mount the file systems on the disk.

    Use Cloud Assistant on a Linux instance

    To use Cloud Assistant to initialize a disk, the following requirements must be met:

    • The multi-attach feature is disabled on the disk that you want to initialize.

    • The disk is attached to a Linux ECS instance, not a Windows instance.

    • The ECS instance is in the Running state, and Cloud Assistant Agent is installed on the instance. For more information, see Install Cloud Assistant Agent.

    • The disk is not a detached system disk.

    • You want to create a GUID Partition Table (GPT) partition and mount a file system of the Extended File System 4 (Ext4) type on the disk.

    截屏2024-12-25 09

    1. Specify the partition size and mount point.

      Note

      You 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.

        Note

        1 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.

        Important

        If the destination directory is not empty, mounting partitions there will hide existing system files, making them unreadable and affecting business operations.

    2. Confirm and select the risk statement and then click OK.

      Note

      If you accidentally close the page, you can use Cloud Assistant to create partitions and file systems again by referring to Method 1: Use Cloud Assistant to automatically initialize a data disk (Invitational Preview).

      When Normal appears in the Current Status column in the initialization task list, the disk is initialized.

    3. (Optional) Configure the system to automatically mount the partitions on instance startup. For details, see (Optional) Step 4: Configure the disk partitions to automatically mount on instance startup.

    Refer to documentation (CLI)

    If you cannot use Cloud Assistant to initialize the disk, perform the following operations:

    Data disk that contains data

    If the data 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. This does not cause data loss.

    Use Cloud Assistant on a Linux instance

    To use Cloud Assistant to initialize a disk, the following requirements must be met:

    • The multi-attach feature is disabled on the disk that you want to initialize.

    • The disk is attached to a Linux ECS instance, not a Windows instance.

    • The ECS instance is in the Running state, and Cloud Assistant Agent is installed on the instance. For more information, see Install Cloud Assistant Agent.

    • The disk is not a detached system disk.

    1. 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.

      Note

      You can specify an existing directory that does not contain data or another directory as a mount point. The mount points cannot be duplicated.

      截屏2024-12-25 09

      Note

      If you accidentally close the page, you can use Cloud Assistant to mount the file system again. For more information, see Method 1: Use Cloud Assistant to automatically initialize a data disk (Invitational Preview).

    2. (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.

    3. (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.

    4. (Optional) Configure the disk partitions to automatically mount on instance startup. For details, see (Optional) Step 4: Configure the disk partitions to automatically mount on instance startup.

    Refer to documentation (CLI)

    If you cannot use Cloud Assistant to mount file systems, perform the following steps:

    1. Mount the partitions of the cloud disk or bring the cloud disk online.

      • Linux instance

        1. Connect to the ECS instance to which the cloud disk is attached and run the following command to mount a partition of the disk:

          sudo mount <Disk partition name> <Mount point>
          • <Disk partition name>: Specify the name of the partition. Run the sudo fdisk -lu command to query the partition name. Example: /dev/vdc.

          • <Mount point>: Specify an existing directory or run the sudo 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.

        2. Write the new partition information to the /etc/fstab file. This way, the partition is automatically mounted upon system startup. For more information, see the (Optional) Step 4: Configure the disk partitions to automatically mount on instance startup section of the "Initialize a data disk on a Linux instance" topic.

      • Windows instance

        1. Connect to the ECS instance to which the cloud disk is attached, click the 开始图标 icon, and then select Disk Management.

        2. Find the cloud disk that you want to manage, right-click a blank area, and then select Online.image

    2. (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.

    3. (Conditionally required) If the cloud disk created from a snapshot is larger than the source disk of the snapshot in size, you must extend the partitions and file systems of the cloud disk before you can use the cloud disk.

    4. (Optional) Configure the partitions of the disk to automatically mount on instance startup. For more information, see the (Optional) Step 4: Configure the disk partition to automatically mount on instance startup section of the "Initialize a data disk on a Linux instance" topic.