All Products
Search
Document Center

Elastic Compute Service:Attach a data disk

Last Updated:Nov 18, 2024

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.

Note

You can also go to the Cloud Disk tab on the Block Storage (Disks) page and choose 更多 > Attach in the Actions column to attach a disk to an ECS instance.

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Instances & Images > Instances.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. Find the ECS instance to which you want to attach a disk and click the ID of the instance.

  5. Click the Block Storage tab and then click Attach Cloud Disk above the disk list.

    执行挂载

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

    Important

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

    Important

    To retain backup data, we recommend that you clear this option.

  7. Click Next.

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

    Why am I unable to use Cloud Assistant to initialize the disk?

    You can use Cloud Assistant to initialize a disk only if the following conditions are met:

    • Multi-attach is not enabled for the disk.

    • The disk is attached to a Linux ECS instance instead of a Windows ECS instance.

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

    • The disk is not a detached system disk.

    • 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

    image

    1. Create partitions and configure mount points.

      Note

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

        Note

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

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

      Important

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

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

    Only mount file systems

    Use Cloud Assistant (only for Linux ECS instances)

    1. In the Partition Disk and Mount File Systems dialog box, configure the Mount Point parameter and click Manually Mount to mount file systems.

      Note

      Enter an existing directory or create a directory as the mount point. Mount points must be unique.

      image

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

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

    2. Mount partitions to the cloud disk or bring the 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 to 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.

          • The example of mount: sudo mount /dev/vdc /data.

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

        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 select Online.image