If a data disk is attached to an Elastic Compute Service (ECS) instance, you can re-initialize the disk to restore the disk to the initial state when the disk was created. This topic describes how to re-initialize a data disk.
Limits
If you delete the snapshot from which your data disk was created, you can continue to use the disk. However, you cannot re-initialize the disk.
Impacts
Before you re-initialize a data disk, make sure that you understand the items described in the following table.
After you re-initialize a data disk, all data that was written to the disk from the point in time when the disk was created to the point in time when the disk was re-initialized is cleared. We recommend that you create a snapshot for the disk to back up disk data before you re-initialize the disk. For more information, see Create a snapshot.
Item | Description |
Impact on a Windows instance |
|
Impact on a Linux instance |
|
Procedure
Step 1: Make preparations
The re-initialization operation clears data from a data disk. Before you re-initialize a data disk, back up the data on the disk to prevent data loss. For more information, see Create a snapshot.
NoteYou are charged for snapshots. For information about the billing of snapshots, see Snapshots.
Attach the data disk to an ECS instance. For more information, see Attach a data disk.
If the disk is an Enterprise SSD (ESSD), check whether the old version of the instant access feature is disabled for the snapshots of the disk. If the old version of the instant access feature is enabled for the snapshots of an ESSD, the ESSD cannot be re-initialized.
(Conditionally required) If you added commands to automatically mount data disk partitions on startup in the /etc/fstab file for a Linux instance, the instance may fail to automatically mount the data disk partitions on startup after the data disk is re-initialized to restore the initial state. In most cases, exceptions occur on startup. We recommend that you comment out the commands that are used to automatically mount data disk partitions in the /etc/fstab file. Perform the following steps:
Run the
vim /etc/fstab
command.Press the
I
key to enter Insert mode.Find each command that is used to mount a partition of the data disk and add a number sign (#) to comment out the command, as shown in the following example:
# /dev/vdb1 /mnt ext4 defaults 0 0
NoteIn this example, /dev/vdb1 is the data disk partition and /mnt is the mount point of the partition. Comment out commands based on your business scenario.
Press the
Esc
key to exit Insert mode and then enter :wq to save the file and exit.
Stop the instance. For more information, see Stop an instance.
ImportantIf an ECS instance uses the pay-as-you-go billing method and resides in a VPC, you must enable the standard mode when you stop the instance. If you enable the economical mode, you may be unable to start the instance after you re-initialize the disks attached to the instance.
If the data disk is an ESSD, make sure that the multi-attach feature is disabled for the disk. You cannot re-initialize ESSDs for which the multi-attach feature is enabled. For more information, see Multi-attach for cloud disks.
Step 2: Re-initialize the data disk
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
Find the ECS instance whose data disk you want to re-initialize, and click the instance ID to go to the Instance Details page.
Click the Block Storage tab, find the data disk that you want to re-initialize, and then click Re-initialize Disk in the Actions column.
In the Re-initialize Disk dialog box, read the notes and click Confirm.
When the disk is re-initialized, the disk re-enters the In Use state.
After the re-initialization is complete, click Start to start the ECS instance.
Select subsequent operations based on the ECS instance type.
Linux instance
If the data disk is empty when it was created, the re-initialization operation restores the disk to the initial state. In the initial state, the data disk does not have data, partitions, or file systems. You must initialize the data disk before you can use the disk. For more information, see Initialize a data disk on a Linux instance.
If the data disk was created from a snapshot, you must remount file systems to the disk as described in the Only mount file systems section of the "Attach a data disk" topic after the disk is re-initialized. All data generated after the data disk was created is lost. The original data, partitions, and file systems of the snapshot are retained on the disk.
Windows instance
If the data disk is empty when it was created, all data and file systems on the disk are lost. You must initialize the data disk as described in Initialize a data disk on a Windows instance.
If the data disk was created from a snapshot, the disk is restored to the initial state when the disk was created from the snapshot. You must remount file systems to the disk as described in the Only mount file systems section of the "Attach a data disk" topic. All data generated after the disk was created is lost.
After you re-initialize the data disk, redeploy applications and configurations on the disk to restore your business at the earliest opportunity.