You can create a data disk from a snapshot. The data on the data disk is the same as the data on the source disk when the snapshot was created. Snapshot-based disk creation allows you to quickly replicate cloud disks in the same zone or across zones for environment cloning or data backup. This topic describes how to create a data disk from a snapshot.
Limits
You cannot create snapshots for local disks or elastic ephemeral disks. Therefore, you cannot create local disks or elastic ephemeral disks from snapshots.
Block storage devices are independent of each other. After you create block storage devices, you cannot merge the storage space of the block storage devices by formatting them. Before you create block storage devices, we recommend that you determine the required number and capacity of the block storage devices based on your business requirements.
Cloud disks created from system disk snapshots can be used only as data disks. You can use a snapshot of a system disk to roll back the system disk and restore disk data. For more information, see Roll back a disk by using a snapshot.
Prerequisites
A snapshot is created for a cloud disk and the snapshot ID is obtained. For more information, see Create a snapshot.
The ID of an Elastic Compute Service (ECS) instance is obtained if you want to attach the data disk to be created from a snapshot to the instance.
Procedure
The following section describes how to create a cloud disk from a snapshot on the Snapshots page in the Elastic Compute Service (ECS) console. You can perform the same operation on the cloud disk buy page or ECS instance buy page. On the cloud disk buy page, click Create from Snapshot in the Storage section. On the ECS instance buy page, click Create from Snapshot in the Data Disk section.
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.
On the Snapshots page, click the Disk Snapshots tab.
Find the snapshot from which you want to create a cloud disk. In the Actions column, click Create Disk.
On the cloud disk buy page, configure the parameters. The following table describes the parameters.
Parameter or section
Description
Parameter or section
Description
Attach
Specify whether to attach the cloud disk that you want to create to an ECS instance.
Not Attach: creates a cloud disk without attaching the disk to an ECS instance.
If you select this option, you can create only pay-as-you-go cloud disks. The cloud disk and the ECS instance to which you want to attach the disk must reside in the same zone. After you create a cloud disk, you cannot change the region and zone of the disk. Exercise caution when you configure the Region and Zone parameters.
Attach to ECS Instance: creates a cloud disk and attaches the disk to an ECS instance.
If you select this option, you must also select a region and then select an ECS instance from the ECS Instance drop-down list.
Billing Method
Specify the billing method of the cloud disk.
Pay-as-you-go: A pay-as-you-go cloud disk can be attached to a subscription or pay-as-you-go ECS instance.
Subscription: A subscription cloud disk can be attached only to a subscription ECS instance.
Cloud Disk
The snapshot information is automatically populated.
Select a disk category and specify a disk capacity.
The disk capacity must be greater than or equal to the size of the snapshot. If the disk capacity is greater than the size of the snapshot, you must repartition the disk or extend partitions and file systems on the cloud disk to ensure that the excess disk capacity can be used.
If the snapshot is less than 2,048 GiB in size and you want to specify a disk capacity that is greater than 2,048 GiB, check whether the source disk of the snapshot uses the GUID Partition Table (GPT) partition style. You can run the
fdisk -lu
command and determine the partition style of a disk based on the value of theDisk label type
parameter in the command output. If the parameter value isgpt
, the disk uses the GPT partition style. If the source disk does not use the GPT partition style, we recommend that you specify a disk capacity that is less than 2,048 GiB to prevent data loss during partitioning. For more information, see Initialize a data disk on a Linux instance.
For information about how to configure other parameters, such as the Multi-attach and Disk Encryption parameters, see Create an empty data disk.
Confirm the configurations and costs and follow the on-screen instructions to complete the purchase.
After a cloud disk is created, you can view the disk on the Cloud Disk tab. However, the cloud disk cannot be directly used on ECS instances.
Perform operations on the created cloud disk.
Cloud disks created from snapshots already have partitions and file systems and do not need to be initialized. You need to only attach the cloud disk to an ECS instance and mount the file systems of the disk in the instance operating system. This way, the file systems can be recognized by the instance operating system and the cloud disk can be used for data storage.
Scenario
What to do next
Scenario
What to do next
You set the Attach parameter to Attach to ECS Instance when you created the cloud disk.
Mount
the partitions of the cloud disk or bring the cloud disk online.Linux instance
Connect to the ECS instance to which the cloud disk is attached and run the following command to
mount
a partition of the disk:sudo mount <Disk partition name> <Mount point>
<Disk partition name>
: Specify the name of the partition. Run thesudo fdisk -lu
command to query the partition name. Example:/dev/vdc
.<Mount point>
: Specify an existing directory or run thesudo mkdir -p <New directory>
command to create a new directory as the mount point. Example:sudo mkdir -p /data
.
Sample
mount
command:sudo mount /dev/vdc /data
.Write the new partition information to the
/etc/fstab
file. This way, the partition is automatically mounted upon system startup. For more information, see the Step 4: Configure the disk partition to automatically mount on instance startup section of the "Initialize a data disk on a Linux instance" topic.
Windows instance
Connect to the ECS instance to which the cloud disk is attached, click the
icon, and then select Disk Management.
Find the cloud disk that you want to manage, right-click a blank area, and then select Online.
(Conditionally required) If the cloud disk created from a snapshot is attached to the Linux ECS instance to which the source disk of the snapshot is attached, the UUID of the new cloud disk conflicts with the UUID of the source disk. You must change the UUID of the new cloud disk. For more information, see Change the UUID of a disk.
(Conditionally required) If the cloud disk created from a snapshot is larger than the source disk of the snapshot in size, you must extend the partitions and file systems of the cloud disk before you can use the cloud disk.
If the cloud disk is attached to a Linux instance, see Extend the partitions and file systems of disks on a Linux instance.
If the cloud disk is attached to a Windows instance, see Extend the partitions and file systems of disks on Windows instances.
(Optional) Configure the partitions of the disk to automatically mount on instance startup. For more information, see the (Optional) Step 4: Configure the disk partition to automatically mount on instance startup section of the "Initialize a data disk on a Linux instance" topic.
You set the Attach parameter to Not Attach when you created the cloud disk.
Attach the cloud disk to an ECS instance and mount the file systems of the cloud disk in the operating system of the instance. For more information, see Attach a data disk.
FAQ
How do I restore the data of an ECS instance from a disk created from a snapshot when an exception occurs on the instance after an attack or intrusion?
If you created a snapshot for the system disk of the instance before an attack or intrusion occurred, you can use the snapshot to roll back the system disk and restore the disk to the state when the snapshot was created. For more information, see Roll back a disk by using a snapshot.
The snapshot created after an attack or intrusion occurred may contain malicious code or tampered data. The following operations are only for reference. You can perform the related operations based on your actual business deployment.
Create a snapshot for the system disk to back up data. For more information, see Create a snapshot.
Re-initialize the system disk and clear data from the system disk. For more information, see Re-initialize a system disk.
Perform the operations that are described in this topic to create a temporary pay-as-you-go cloud disk from the snapshot that you created.
Attach the temporary cloud disk that you created to the ECS instance as a data disk. For more information, see Attach a data disk.
Copy the business data from the temporary cloud disk to the system disk of the ECS instance and redeploy the business, including applications and configurations, based on your business scenario.
Detach and release the temporary cloud disk. For more information, see Detach a data disk and Release a disk.