全部產品
Search
文件中心

Elastic Compute Service:DetachDisk - 卸載隨用隨付資料盤或系統硬碟

更新時間:Apr 04, 2026

從一台ECS執行個體上卸載一塊隨用隨付的資料盤或者系統硬碟。

介面說明

調用該介面時,請注意:

  • 該介面為非同步作業,調用成功後等待一分鐘左右才能完成卸載。

  • 所掛載的執行個體被安全控制後,OperationLocks中不能標記為"LockReason" : "security"的鎖定狀態。

  • 彈性臨時盤一旦卸載,只能重新掛載至其原始執行個體。

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

調試

授權資訊

下表是API對應的授權資訊,可以在RAM權限原則語句的Action元素中使用,用來給RAM使用者或RAM角色授予調用此API的許可權。具體說明如下:

  • 操作:是指具體的許可權點。

  • 存取層級:是指每個操作的存取層級,取值為寫入(Write)、讀取(Read)或列出(List)。

  • 資源類型:是指操作中支援授權的資源類型。具體說明如下:

    • 對於必選的資源類型,用前面加 * 表示。

    • 對於不支援資源級授權的操作,用全部資源表示。

  • 條件關鍵字:是指雲產品自身定義的條件關鍵字。

  • 關聯操作:是指成功執行操作所需要的其他許可權。操作者必須同時具備關聯操作的許可權,操作才能成功。

操作

存取層級

資源類型

條件關鍵字

關聯操作

ecs:DetachDisk

update

*Disk

acs:ecs:{#regionId}:{#accountId}:disk/{#diskId}

*Instance

acs:ecs:{#regionId}:{#accountId}:instance/{#instanceId}

請求參數

名稱

類型

必填

描述

樣本值

InstanceId

string

待卸載的磁碟所綁定的 ECS 執行個體 ID。

i-bp67acfmxazb4p****

DiskId

string

待卸載的磁碟 ID。

  • 磁碟必須已經掛載到執行個體上,狀態為使用中(In_use)。

  • 卸載資料盤時,所掛載的執行個體必須處於運行中(Running)或者已停止(Stopped)狀態。

  • 卸載系統硬碟時,所掛載的執行個體必須處於已停止(Stopped)狀態。

d-bp67acfmxazb4p****

DeleteWithInstance

boolean

卸載系統硬碟或資料盤時,設定自動釋放屬性。表示釋放 ECS 執行個體時,是否同時釋放該系統硬碟或資料盤。

  • true:釋放。

  • false:不釋放。雲端硬碟被轉換為隨用隨付資料盤被保留下來。

預設值:true

您需要注意:

  • 開啟多重掛載特性的雲端硬碟,不支援設定該參數。

  • 如果卸載的是資料盤,預設值為false

  • 若您需要卸載的目標磁碟為彈性臨時盤,則必須將DeleteWithInstance參數設定為true

false

返回參數

名稱

類型

描述

樣本值

object

RequestId

string

請求 ID。

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

樣本

正常返回樣本

JSON格式

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

錯誤碼

HTTP status code

錯誤碼

錯誤資訊

描述

400 InvalidParameter The input parameter is mandatory for processing this request is empty. 參數不可為空。
400 InvalidRegionId.MalFormed The specified RegionId is not valid.
400 InvalidOperation.InstanceTypeNotSupport The instance type of the specified instance does not support hot detach disk. 磁碟掛載的執行個體不支援磁碟熱插拔操作。
400 DisksDetachingOnEcsExceeded The number of disks detaching on the instance exceeds the limit. 執行個體上正在卸載的磁碟個數超過限制
400 InvalidInstanceId.Malformed The specified parameter InstanceId is not valid. 指定的參數InstanceId格式有誤。
500 InternalError The request processing has failed due to some unknown error.
403 IncorrectDiskStatus The current disk status does not support this operation.
403 DiskNotPortable The specified disk is not a portable disk.
403 InstanceLockedForSecurity The instance is locked due to security. 您的資源被安全鎖定,拒絕操作。
403 DependencyViolation The specified disk has not been attached on the specified instance.
403 DiskTypeViolation The specified disk is a system disk and cannot support the operation. 指定的雲端硬碟是系統硬碟,不能卸載。
403 IncorrectInstanceStatus The current status of the resource does not support this operation.
403 UserNotInTheWhiteList The user is not in disk white list. 您不在磁碟白名單中,請加入白名單後重試。
403 InvalidInstance.ImageCategory The image category of the specified instance does not support detaching system disk. 指定執行個體的鏡像狀態不支援卸載指定的系統硬碟。可能原因:建立執行個體時使用的鏡像被刪除。
403 DeleteWithInstance.Conflict Multi attach disk cannot be set to DeleteWithInstance attribute. 開啟多重掛載特性的雲端硬碟不支援設定 DeleteWithInstance。
403 InvalidOperation.DiskCategoryUnsupported The DetachDisk operation is not supported for elastic ephemeral disk. 彈性臨時盤不支援單獨卸載
403 InvalidParameter.DeleteWithInstance The DeleteWithInstance for the elastic ephemeral disk must be set to true. 彈性臨時盤的 DeleteWithInstance 屬性必須設定為 true。
403 InvalidOperation.DiskDetachingFromThisEcs The specified disk is detaching from this ecs. 磁碟正在從當前執行個體上卸載。
404 InvalidInstanceId.NotFound The specified InstanceId does not exist. 指定的執行個體ID無效。
404 InvalidDiskId.NotFound The specified disk does not exist. 指定的磁碟不存在。請您檢查磁碟 ID 是否正確。
404 InvalidDisk.AlreadyDetached The specified disk has been detached.
404 InvalidDiskId.OperationNotSupported The operation is not supported due to base image not exist.

訪問錯誤中心查看更多錯誤碼。

變更歷史

更多資訊,參考變更詳情