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:
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.
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
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.
Log on to the ECS instance.
Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.
On the instance details page, click Connect > Workbench. Follow the prompts to log on.
Run
sudo df -hto find the device name in theFilesystemcolumn and its mount point in theMounted oncolumn.In this example,
/dev/vdb1is 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/0Unmount the file system.
Replace
<device name>with the device name from the previous step.sudo umount <device name>Remove automatic mount configurations to prevent restart failures.
Run
cat /etc/fstabto 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/fstaband 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.
Log on to the ECS instance.
Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.
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.
Take the disk offline.
Right-click the
icon and select Disk Management.In the Disk Management window, right-click the target disk and select Offline.

Step 2: Detach the data disk
Sever the connection between the cloud disk and the ECS instance.
Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.
Click the target instance ID to go to the instance details page, and then click the Block Storage tab.
In the Actions column for the target disk, click Detach.
In the dialog box that appears, click OK.
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.

FAQ
What should I do if my Linux instance fails to start after I detach a data disk?
This is usually caused by leftover automatic mount entries for the detached disk in
/etc/fstab. See What do I do if system startup exceptions occur due to configuration errors in the /etc/fstab file on a Linux instance?
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.
Log on to the ECS instance.
Go to ECS console - Instances. In the top-left corner, select the region and resource group for the target resource.
On the instance details page, click Connect > Workbench. Set the connection method to Terminal. Enter your credentials to log on to the graphical terminal.
Identify the process that is using the disk.
Right-click the
icon and select Event Viewer.In the Event Viewer window, choose .
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.

Terminate the process.
ImportantTerminating a process may cause data loss or service interruption. Ensure the process is not critical and has no pending write operations.
Right-click the
icon and select Task Manager.Click Details. Find the target process by name or ID.
Right-click the target process, click End Task, and detach the data disk again.
View the last attached instance of a disk
Navigate to ECS console - Elastic Block Storage - Disks
Find disks with the Unattached status. In the Tag column, hover over the
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:lastAttachedInstanceshows the last attached instance ID.
References
Detach a data disk with the DetachDisk API operation.
Attach a detached disk to another ECS instance in the same zone.
If you no longer need the disk, create a snapshot to back up its data and then release the disk.