You can call this operation to reinitialize a disk to restore it to the status when it was created.

Description

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

  • The operation can be performed only when the disk is in the In Use state and the instance to which the disk is attached must be in the Stopped state.
  • If the instance has not been started since it was created, the disks attached to it cannot be reinitialized.
  • The system disk will be restored to the initial status when it was created. If the source image used to create the disk is deleted, the disk cannot be initialized.
  • A user-created data disk will be initialized to the state of an empty data disk.
  • A data disk that is created from a snapshot will be initialized to the state of the snapshot. If the source snapshot used to create the disk is deleted, the disk cannot be initialized and an error will be returned.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
DiskId String Yes d-bp67acfmxazb4ph***

The ID of the disk.

Action String Yes ReInitDisk

The operation that you want to perform. Set the value to ReInitDisk.

AutoStartInstance Boolean No true

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

Default value: false.

KeyPairName String No JoshuaCentOS

The name of the key pair.

Note The parameter is applicable only to Linux instances. You can bind an SSH key pair to an instance as the logon credential when you reinitialize its system disk. However, after you bind the SSH key pair, the password logon method is disabled.
Password String No EcsV587!

Specifies whether to reset the password of the instance when you reinitialize its system disk. The password must be 8 to 30 characters in length. It must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include


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

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

Note If the Password parameter is specified, we recommend that you send requests over HTTPS to secure your password.
SecurityEnhancementStrategy String No Active

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

  • Active: Security Center is used for free after the system disk is reinitialized. This value is applicable only to public images.
  • Deactive: Security Center is not used for free after the system disk is reinitialized. This value is applicable to all images.

Default value: Deactive.

Response parameters

Parameter Type Example Description
RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=ReInitDisk
&DiskId=d-bp67acfmxazb4ph***
&KeyPairName=JoshuaCentOS
&AutoStartInstance=true
&SecurityEnhancementStrategy=Active
&<Common request parameters>

Sample success responses

XML format

<ReInitDiskResponse>
      <RequestId>F3CD6886-D8D0-4FEE-B93E-1B73239673DE</RequestId>
</ReInitDiskResponse>

JSON format

{
	"RequestId":"F3CD6886-D8D0-4FEE-B93E-1B73239673DE"
}

Error codes

HTTP status code Error code Error message Description
404 InvalidDiskId.NotFound The specified disk does not exist. The error message returned because the specified DiskId parameter does not exist. Check whether the disk ID is correct.
403 IncorrectDiskStatus The current disk status does not support this operation. The error message returned because the operation is not supported while the disk is in the current state. Ensure that the disk is available and has no overdue payments.
403 IncorrectInstanceStatus The current status of the resource does not support this operation. The error message returned because the operation is not supported while the resource is in the current state.
403 InstanceLockedForSecurity The instance is locked due to security. The error message returned because the operation is not supported while the resource 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. The error message returned because the specified snapshot is created on or before July 15, 2013.
403 OperationDenied The snapshot which is used to create the specified disk has been deleted. The error message returned because the snapshot used to create the specified disk does not exist.
403 InstanceExpiredOrInArrears The specified operation is denied as your prepay instance is expired (prepay mode) or in arrears (afterpay mode). The error message returned because the subscription instance has expired. Renew the instance first.
403 DiskCreatingSnapshot The operation is denied due to a snapshot of the specified disk is not completed yet. The error message returned because a snapshot of the specified disk is being created.
403 InvalidSourceSnapshot The snapshot which is used to create the specified disk has been deleted. The error message returned because the snapshot used to create the specified disk has been deleted.
404 InvalidImageId.NotFound The specified ImageId does not exist. The error message returned because the specified image does not exist under this account. Check whether the image ID is correct.
403 SharedImageDeleted The specified image by others shared is deleted. The error message returned because the specified shared image has been deleted.
400 InvalidPassword.Malformed The specified parameter "Password" is not valid. The error message returned because the specified Password parameter is invalid.
400 DiskCategory.OperationNotSupported The operation is not supported to the specified disk due to its disk category The error message returned because the specified disk category does not support the operation.
400 InvalidKeyPairName.NotFound The specified KeyPairName does not exist. The error message returned because the specified KeyPairName parameter does not exist.
400 DependencyViolation.IoOptimize The specified parameter InstanceId is not valid. The error message returned because the specified InstanceId parameter is invalid.
400 InvalidRegionId.MalFormed The specified RegionId is not valid The error message returned because the specified RegionId parameter is invalid.
404 InvalidDiskId.OperationNotSupported The operation is not supported due to image not exist. The error message returned because the specified DiskId parameter is invalid.

For a list of error codes, visit the API Error Center.