All Products
Search
Document Center

Elastic Compute Service:Detach a data disk

Last Updated:Apr 15, 2026

Detach a data disk from an ECS instance to migrate it to another instance or release it.

How it works

Detaching a data disk involves two steps:

  1. Unmount the file system in the operating system: Like safely ejecting a USB drive. This prevents data corruption from interrupted read/write operations during detachment.

  2. Detach the data disk from the instance: Like unplugging the USB drive after ejection. This severs the connection between the cloud disk and the ECS instance.

Usage notes

  • Subscription cloud disks cannot be detached directly. Switch the billing method to pay-as-you-go first.

  • Detaching local disks is not supported.

Procedure

Important

Before you begin, pause all read and write operations on the data disk and stop all processes using it to prevent data loss.

Step 1: Unmount the file system in the operating system

Prevent the operating system from accessing the data disk to ensure data integrity. If the instance is Stopped, skip to Step 2: Detach the data disk.

Linux

These standard Linux commands apply to all major distributions, such as CentOS, Ubuntu, and Debian.

  1. Log on to the ECS instance.

    1. Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.

    2. On the instance details page, click Connect > Workbench. Follow the prompts to log on.

  2. Run sudo df -h to find the device name in the Filesystem column and its mount point in the Mounted on column.

    In this example, /dev/vdb1 is mounted on /mnt.

    $ sudo df -h
    Filesystem      Size  Used Avail Use% Mounted on
    devtmpfs        868M     0  868M   0% /dev
    tmpfs           879M     0  879M   0% /dev/shm
    tmpfs           879M  508K  878M   1% /run
    tmpfs           879M     0  879M   0% /sys/fs/cgroup
    /dev/vda1        40G  2.4G   36G   7% /
    /dev/vdb1        40G   49M   38G   1% /mnt
    tmpfs           176M     0  176M   0% /run/user/0
  3. Unmount the file system.

    Replace <device name> with the device name from the previous step.

    sudo umount <device name>
  4. Remove automatic mount configurations to prevent restart failures.

    Run cat /etc/fstab to check if the mount point from Step 2 exists.

    • If it does not exist, proceed to Step 2: Detach the data disk.

    • If it exists, run sudo vi /etc/fstab and add # at the beginning of the mount line to comment it out. Save the file and proceed to Step 2: Detach the data disk.

      In this example, comment out UUID=32532395-51a7-46f7-b83d-181158b009a0 /mnt ext4 defaults 0 0.

      # /etc/fstab
      # Created by anaconda on Fri Jun 28 04:16:23 2024
      #
      # Accessible filesystems, by reference, are maintained under '/dev/disk'
      # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
      #
      UUID=c8b5b2da-5565-4dc1-b002-2a8b07573e22 /                       ext4    defaults        1 1
      UUID=32532395-51a7-46f7-b83d-181158b009a0 /mnt ext4 defaults 0 0
      ~                                                              

Windows

This topic uses Windows Server 2022 as an example.

  1. Log on to the ECS instance.

    1. Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.

    2. On the instance details page, click Connect > Workbench. Set the connection method to Terminal Connection, enter your credentials, and log on to the graphical terminal.

  2. Take the disk offline.

    1. Right-click the Start icon icon and select Disk Management.

    2. In the Disk Management window, right-click the target disk and select Offline.

      Offline

Step 2: Detach the data disk

Sever the connection between the cloud disk and the ECS instance.

  1. Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.

  2. Click the target instance ID to go to the instance details page, and then click the Block Storage tab.

  3. In the Actions column for the target disk, click Detach.

  4. In the dialog box that appears, click OK.

  5. View the detachment result.

    Go to the ECS console > Block Storage > Cloud Disk page. The disk Status changes to Unattached and is tagged with acs:ecs:lastAttachedInstance.

    The tag value is the last attached instance ID.

    image

FAQ

  • What should I do if a cloud disk's status remains Detaching on a Windows instance?

    Cause: A process prevents the disk from being unmounted.

    The following steps use Windows Server 2022 as an example.

    1. Log on to the ECS instance.

      1. Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.

      2. On the instance details page, click Connect > Workbench. Set the connection method to Terminal. Enter your credentials to log on to the graphical terminal.

    2. Identify the process that is using the disk.

      1. Right-click the Start icon icon and select Event Viewer.

      2. In the Event Viewer window, choose Windows Logs > System.

      3. In the system logs, look for warning events to identify the name and PID of the process that is using the disk.

        In this example, the process name is OpenHardwareMonitor.exe and the PID is 3980.

        image

    3. Terminate the process.

      Important

      Terminating a process may cause data loss or service interruption. Ensure the process is not critical and has no pending write operations.

      1. Right-click the Start icon icon and select Task Manager.

      2. Click Details. Find the target process by name or ID.

      3. Right-click the target process, click End Task, and detach the data disk again.

  • View the last attached instance of a disk

    1. Navigate to ECS console - Elastic Block Storage - Disks

    2. Find disks with the Unattached status. In the Tag column, hover over the edit-tag icon.

      • If the disk has no attachment information, it has never been attached to an ECS instance.

      • If the disk has attachment information, the tag key acs:ecs:lastAttachedInstance shows the last attached instance ID.

        image

References