When a data disk is attached to an Elastic Compute Service (ECS) instance, you can reinitialize the disk to restore it to the status when it was created.
- The data disk has been attached to an instance. For more information about how to attach a data disk to an instance, see Attach a cloud disk.
- For an instance that runs Linux, you can add a command in the /etc/fstab file to mount partitions of a data disk at the startup of the instance. If the data
disk was empty when it was created, after you reinitialize the data disk, the command
will not be executed and the instance cannot start up as expected. We recommend that
you comment out the command in the /etc/fstab file. The procedure is as follows:
- Remotely connect to an instance that runs Linux.
- Run the
- Press the
ikey to enter the editing mode.
- Find the command used to mount data disk partitions and comment it out by using #, as shown in the following line.
# /dev/vdb1 /InitTest ext3 defaults 0 0Note /dev/vdb1 is an example partition and /InitTest is an example mount point. You can replace them based on your business requirements.
- Press the
Esckey to exit the editing mode. Then, enter :wq to save any changes and exit the vim editor.
- The data disk is restored to the initial status when it was created:
- It becomes an empty disk if it was originally an empty disk.
- It stores the data recorded in the source snapshot if it was created from a snapshot.
- For an instance that runs Windows, after you reinitialize its data disk, the data disk is ready for use without any additional operations regardless of its original status.
- For an instance that runs Linux:
- If the data disk was created from a snapshot, it stores only the data recorded in the source snapshot after being reinitialized. You do not need to mount the partitions again, but all the data generated after the disk creation is lost.
- If the data disk was created as an empty disk, all the data and partitions on the disk are lost. You must partition and format the disk, and mount the partitions again.
- Log on to the ECS console.
- In the left-side navigation pane, choose .
- In the top navigation bar, select a region.
- Find the ECS instance where you need to reinitialize a data disk, and click the instance ID to go to the Instance Details page.
- Click Stop in the upper-right corner of the page to stop the instance.
- After the instance is Stopped, click Disks in the left-side navigation pane.
- Find the target data disk, and click Reinitialize Disk in the Actions column.
- In the Reinitialize Disk dialog box, read the notes and click Confirm.
- In the left-side navigation pane, click Instance Details.
- Click Start in the upper-right corner of the page to start the instance and complete the reinitialization of the data disk.
What to do next
- If a data disk is mounted to an instance running Linux and the data disk was created as an empty disk, you must format the disk after you reinitialize it. For more information, see Format a data disk of a Linux instance.
- After the data disk is reinitialized, you need to deploy and configure applications to restore your business as soon as possible.