全部產品
Search
文件中心

Elastic Compute Service:DetachDisk

更新時間:Sep 14, 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.
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 system disk cannot be detached because it was created from a marketplace image. Please use a system disk created from a custom or public image.
403 DeleteWithInstance.Conflict Multi attach disk cannot be set to DeleteWithInstance attribute. 指定的磁碟不是可卸載磁碟,不支援隨執行個體釋放。
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.
429 Throttling The request was denied due to request throttling. Please retry later.

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

變更歷史

更多資訊,參考變更詳情。