All Products
Search
Document Center

Elastic Compute Service:Use a snapshot of the original system disk to restore data after the operating system of an ECS instance is replaced

Last Updated:Mar 28, 2025

When you replace the operating system of an Elastic Compute Service (ECS) instance, the system disk and the image of the instance are also replaced. The original system disk is released and all data stored on the disk is deleted. As a result, you cannot use a snapshot of the original system disk to roll back the new system disk. This topic describes how to use a snapshot of the original system disk to restore disk data after you replace the operating system of an ECS instance.

Prerequisites

  • A snapshot is created for the original system disk of the ECS instance whose operating system is replaced. The snapshot ID is obtained. For more information, see Create a snapshot.

Note

You are charged for snapshots. For information about the billing of snapshots, see Snapshots.

Procedure

Step 1: Create a data disk from a snapshot of the original system disk

  1. Go to ECS console - Snapshots.

  2. In the top navigation bar, select the region and resource group of the resource that you want to manage. 地域

  3. On the Disk Snapshots tab, find a snapshot of the original system disk of an ECS instance whose operating system is replaced. In the Actions column, click Create Disk.

  4. Set the Attach parameter to Attach to ECS Instance and enter the ID of the ECS instance. For information about how to configure other parameters on the disk buy page, see Create a data disk from a snapshot.

  5. Confirm the configurations and costs and follow the on-screen instructions to complete the purchase.

Step 2: Log on to the ECS instance and restore data

In this example, an ECS instance whose Alibaba Cloud Linux 3.2104 operating system is replaced is used. The required operations may vary based on the operating system.

  1. Connect to the ECS instance.

  2. Run the following command to obtain the device names of the data disks:

    sudo fdisk -lu

    截屏2025-01-17 10

    In this example, the following partitions exist on the data disk created from a snapshot of the original system disk:

    First partition /dev/vdb1: stores the boot loader to ensure that the operating system can boot from the disk as expected.

    Second partition /dev/vdb2: stores the Extensible Firmware Interface (EFI) boot program to ensure that the operating system can boot by using EFI firmware.

    Third partition /dev/vdb3: stores the required operating system files and data to restore the data of the original system disk.

    The partitions may vary based on the operating system.

  3. Run the following command to create a directory. In this example, the /temporary directory is created. Replace /temporary with an actual directory name.

    sudo mkdir -p /temporary
  4. Run the following command to mount a file system. In this example, a file system in the /dev/vdb3 partition of the data disk is mounted to the /temporary directory. Replace /dev/vdb3 and /temporary with the actual values.

    sudo mount /dev/vdb3 /temporary
  5. Run the following command to copy files. In this example, files in the /mnt directory of the original system disk are copied to the /mnt directory of the new system disk.

    sudo cp -v /temporary/mnt/* /mnt

    You can also install the rsync utility and use the utility to copy the files from the original system disk to the new system disk and view the copy progress.

    sudo yum install -y rsync
    rsync --progress /temporary/mnt/* /mnt

Step 3: Check whether your business runs as expected

  1. Check whether your business is restored. After you restore the data of the original system disk, we recommend that you restart the relevant services on the ECS instance and check whether your business runs as expected.

  2. After you confirm that your business runs as expected, detach the data disk created from the snapshot of the original system disk and release the data disk. For more information, see Detach a data disk and Release a disk.