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

Description

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

  • The disk to be re-initialized must be in the In Use (In_use) state and the instance to which the disk is attached must be in the Stopped (Stopped) state.
  • If an instance has never been started since it was created, its attached disks cannot be re-initialized.
  • If a local snapshot has been created for a disk, the disk cannot be re-initialized.
  • When a system disk is re-initialized, it is restored to the state of the image from which it was created. If the source image is deleted, the system disk cannot be re-initialized.
  • When a separately created data disk is re-initialized, it is restored to an empty data disk.
  • When a data disk that is created from a snapshot is re-initialized, the disk is restored to the state of the source snapshot.
Note If the source snapshot is deleted, the disk cannot be re-initialized and an error is returned.

Debugging

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

Request parameters

Parameter Type Required Example Description
Action String Yes ReInitDisk

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

DiskId String Yes d-bp67acfmxazb4ph****

The ID of the disk.

Password String No EcsV587!

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


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

For a Windows instance, 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.
KeyPairName String No testKeyPairName

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 re-initialize its system disk. After the SSH key pair is bound, the username and password logon method is disabled for the instance.
AutoStartInstance Boolean No true

Specifies whether to automatically start the instance after the disk is re-initialized.

Default value: false.

SecurityEnhancementStrategy String No Active

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

  • Active: Security Center is used for free after the system disk is replaced. This value is applicable only to public images.
  • Deactive: Security Center is not used for free after the system disk is replaced. 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=testKeyPairName
&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. Make sure that the disk is available and your account has no overdue payment for it.
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 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. The error message returned because 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. 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 is deleted.
404 InvalidImageId.NotFound The specified ImageId does not exist. The error message returned because the specified image does not exist in 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 is 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 I/O optimization of the instance is invalid.
403 UserNotInTheWhiteList The user is not in volume white list. The error message returned because you are not in the Shared Block Storage whitelist. Submit a ticket to apply for the permission.
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 image does not exist.
403 InvalidParameter.KMSKeyId.KMSUnauthorized ECS service have no right to access your KMS. The error message returned because ECS is not authorized to access your KMS resources.
500 InternalError The request processing has failed due to some unknown error, exception or failure. The error message returned because an internal error has occurred. Try again later. If the problem persists, submit a ticket.

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