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.

Prerequisites

  • 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:
    1. Remotely connect to an instance that runs Linux.
    2. Run the vim /etc/fstab command.
    3. Press the i key to enter the editing mode.
    4. 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 0
      Note /dev/vdb1 is an example partition and /InitTest is an example mount point. You can replace them based on your business requirements.
    5. Press the Esc key to exit the editing mode. Then, enter :wq to save any changes and exit the vim editor.

Background information

The status of a data disk after being reinitialized varies depending on its original status when it was created and the operating system the instance runs:
  • 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.

Procedure

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Instances & Images > Instances.
  3. In the top navigation bar, select a region.
  4. Find the ECS instance where you need to reinitialize a data disk, and click the instance ID to go to the Instance Details page.
  5. Click Stop in the upper-right corner of the page to stop the instance.
  6. After the instance is Stopped, click Disks in the left-side navigation pane.
  7. Find the target data disk, and click Reinitialize Disk in the Actions column.
  8. In the Reinitialize Disk dialog box, read the notes and click Confirm.
  9. In the left-side navigation pane, click Instance Details.
  10. 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.