All Products
Search
Document Center

Elastic Compute Service:ReInitDisk

Last Updated:Jun 19, 2026

Reinitializes a disk to its initial state when it was created.

Operation description

When you call this operation, take note of the following items:

  • The disk must be in the In Use (In_use) state, and the ECS instance to which the disk is attached must be in the Stopped (Stopped) state.

  • You cannot reinitialize a disk that is attached to an instance before the instance starts for the first time.

  • You cannot reinitialize a disk that has local snapshots.

  • For a system disk, the disk is reinitialized to the initial state of the image. If the source image used to create the disk has been deleted, the disk cannot be reinitialized.

  • For a data disk that was created from scratch, the disk is reinitialized to an empty disk. For a data disk that was created from a snapshot, the disk is reinitialized to the snapshot state. If the source snapshot has been deleted, the disk cannot be reinitialized and an error is returned.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:ReInitDisk

update

*Disk

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

  • ecs:PasswordCustomized
None

Request parameters

Parameter

Type

Required

Description

Example

DiskId

string

Yes

The ID of the disk to be reinitialized.

d-bp67acfmxazb4ph****

Password

string

No

Specifies whether to reset the username and password of the ECS instance when the system disk is reinitialized. The password must be 8 to 30 characters in length and must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. The following special characters are supported:

()`~!@#$%^&*-_+=|{}[]:;'<>,.?/

For Windows instances, the password cannot start with a forward slash (/).

Note

If you specify the Password parameter, use HTTPS to send the request to avoid password leaks.

EcsV587!

KeyPairName

string

No

The name of the key pair.

Note

This parameter is applicable only to Linux instances. When the system disk is reinitialized, you can attach an SSH key pair to the ECS instance as the logon credential. After you use an SSH key pair, the username and password logon method is disabled.

testKeyPairName

AutoStartInstance

boolean

No

Specifies whether to automatically start the instance after the disk is reinitialized. Valid values:

  • true: automatically starts the instance.

  • false: does not automatically start the instance.

Default value: false.

true

SecurityEnhancementStrategy

string

No

Specifies whether to use the free Security Center service after the system disk is reinitialized. Valid values:

  • Active: uses the Security Center service. This value is applicable only to public images.

  • Deactive: does not use the Security Center service. This value is applicable to all images.

Default value: Deactive.

Active

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Examples

Success response

JSON format

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

Error codes

HTTP status code

Error code

Error message

Description

400 LoginAsNonRoot.ImageNotSupport The specified image does not support login as non-root. The image does not support the logons of non-root users.
400 DiskHasSnapshotsWithInstantAccessEnabled.OperationNotSupported The operation is not supported to the specified disk that have snapshots with InstantAccess enabled.
400 InvalidPassword.Malformed The specified parameter "Password" is not valid.
400 InvalidKeyPairName.NotFound The specified KeyPairName does not exist. The specified KeyPairName parameter does not exist.
400 DependencyViolation.IoOptimize The specified parameter InstanceId is not valid. The I/O optimization configuration of the instance is invalid.
400 DiskCategory.OperationNotSupported The operation is not supported to the specified disk due to its disk category. The specified disk category does not support this operation.
400 InvalidRegionId.MalFormed The specified RegionId is not valid.
500 InternalError The request processing has failed due to some unknown error, exception or failure. An internal error has occurred. Try again later.
403 LoginAsNonRoot.RegionNotSupport The specified region does not support login as non-root.
403 IncorrectDiskStatus The current disk status does not support this operation.
403 IncorrectInstanceStatus The current status of the resource does not support this operation.
403 InstanceLockedForSecurity The instance is locked due to security. The operation is not supported while the instance is locked for security reasons.
403 InvalidSnapshot.TooOld The disk is created from a snapshotId made before 2013-07-15, it cannot be re-initiated the specified disk any more since the detached first time. Snapshots created before July 15, 2013 do not support this operation.
403 OperationDenied The snapshot which is used to create the specified disk has been deleted.
403 InstanceExpiredOrInArrears The specified operation is denied as your prepay instance is expired (prepay mode) or in arrears (afterpay mode).
403 DiskCreatingSnapshot The operation is denied due to a snapshot of the specified disk is not completed yet.
403 SharedImageDeleted The specified image by others shared is deleted.
403 DependencyViolation.WindowsInstance The instance creating is windows, cannot use ssh key pair to login.
403 InvalidDisk.DiskFromClonedNotSupport The specified disk %s is cloned from source disk %s, so not support reinit
403 UserNotInTheWhiteList The user is not in volume white list.
403 InvalidParameter.KMSKeyId.CMKNotEnabled The CMK needs to be enabled.
403 InvalidParameter.KMSKeyId.KMSUnauthorized ECS service have no right to access your KMS. ECS is not authorized to access your KMS resources.
403 HibernationConfigured.InstanceOperationForbidden The operation is not permitted due to limit of the hibernation configured instance. The operation cannot be performed due to the limitations of instances for which the instance hibernation feature is enabled.
403 InvalidOperation.MultiAttachDisk Multi attach disk does not support this operation. Disks for which the multi-attach feature is enabled do not support the operation.
403 InvalidParameter.KMSKeyId.CMKUnauthorized The CMK needs to be added ECS tag.
403 InvalidSourceSnapshot The source snapshot of the disk has been deleted and cannot support the current operation. The source snapshot of the disk has been deleted and cannot support the current operation.
403 InvalidOperation.ReInitUnsupported The specified disk does not support reInit. The specified cloud disk does not support reinitialization.
404 InvalidDiskId.NotFound The specified disk does not exist. The specified disk does not exist. Check whether the disk ID is correct.
404 InvalidImageId.NotFound The specified ImageId does not exist. The specified image does not exist in this account. Check whether the image ID is correct.
404 InvalidDiskId.OperationNotSupported The operation is not supported due to image not exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.