Recovering a disk from a snapshot
Note
You cannot recover a boot disk of an existing VM from a snapshot or image. However, you can create a new VM to recover a boot disk from a snapshot. To recover the boot disk of an existing VM, use Yandex Cloud Backup.
To create a disk from a snapshot:
-
In the management console
, select the folder where you want to create a disk. -
Select Compute Cloud.
-
In the left-hand panel, select
Disks. -
Click Create disk.
-
Enter a name for the disk. The naming requirements are as follows:
- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
Provide a description for the disk, if required.
-
Select the availability zone the disk will reside in.
-
In the Contents field, select
Snapshotand select your snapshot from the list that opens. Optionally, use the filter. -
Set the disk parameters: disk type, disk size, and block size.
-
Optionally, under Encryption:
- Select Encrypted disk.
- In the KMS key field, select the key you created earlier. To create a new key, click Create.
To create an encrypted disk, you need the
kms.keys.userrole or higher.Warning
You can specify encryption settings only when creating a disk. You cannot disable or change disk encryption. You also cannot enable encryption for an existing disk.
If you deactivate the key used to encrypt a disk, image, or snapshot, access to the data will be suspended until you reactivate the key.
Alert
If you destroy the key or its version used to encrypt a disk, image, or snapshot, you will irrevocably lose access to the data. For details, see Destroying key versions.
-
Optionally, select or create a schedule for automatic disk snapshots. For more information about setting up schedules, see this guide.
You can create snapshots of network disks and drives, such as HDDs, SSDs, and non-replicated SSDs, as well as ultra high-speed network storages with three replicas (SSD).
For non-replicated SSDs and ultra high-speed network storages with three replicas (SSD), the snapshot time is not determined.
To create snapshots of local disks residing on dedicated hosts, use Yandex Cloud Backup. This service supports Ubuntu, CentOS, CentOS Stream, and Windows Server.
When creating a disk, you can only select a single snapshot schedule. After the disk is created, you can add a few more schedules by following this guide.
-
Optionally, expand the Additional section and, in the Hardware generation field, select the virtualized hardware generation you want to assign to the new disk:
Gen 1.2 (MBR, BIOS):Gen 1.2.Gen 1.1 (MBR, BIOS):Gen 1.1.
If you make no assignment, by default the disk will get the same generation assigned as the source snapshot.
-
Click Create disk.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
-
View the description of the CLI command to create a disk:
yc compute disk create --help -
Get a list of snapshots in the default folder:
yc compute snapshot listResult:
+----------------------+----------------------+----------------------+----------+ | ID | NAME | PRODUCT IDS | STATUS | +----------------------+----------------------+----------------------+----------+ | fd84hanhvjql******** | disk-1-1668075122980 | f2ef3frbftr2******** | READY | | fd85mc22cosp******** | disk-2-1669114692462 | f2ef3frbftr2******** | READY | +----------------------+----------------------+----------------------+----------+ -
Select
IDorNAMEof the snapshot you need. -
Create a disk from the selected snapshot:
yc compute disk create \ --name <disk_name> \ --source-snapshot-name <source_snapshot_name> \ --zone <availability_zone> \ --description <text_description_of_disk> \ --hardware-generation-id <hardware_generation> \ --hardware-features pci_topology=<PCI_topology>Where:
-
--name: Disk name. Follow these naming requirements:- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
--source-snapshot-name: Source snapshot name. Instead of a name, you can provide the source snapshot ID in the--source-snapshot-idparameter. -
--zone: Availability zone of the new disk. -
--description: Text description of the new disk. This is an optional parameter. -
--hardware-generation-id: Hardware generation assigned to the disk. This is an optional parameter. Possible values:legacy:Gen 1. If you select this generation, you can also specify the PCI topology in the--hardware-featuresparameter.
If not specified, the disk will get the same hardware generation assigned as the source snapshot.
-
--hardware-features: Additional settings forGen 1. This is an optional parameter. Possible values:pci_topology=v1:PCI_TOPOLOGY_V1topology.pci_topology=v2:PCI_TOPOLOGY_V2topology.
If the source snapshot has
Gen 1assigned, by default the new disk will get the same--hardware-featuresvalue as the source snapshot.
Result:
done (44s) id: epdbnjirsai9******** folder_id: b1gt6g8ht345******** created_at: "2025-06-23T14:46:22Z" name: second-disk description: my second disk via yc type_id: network-hdd zone_id: ru-central1-a size: "21474836480" block_size: "4096" product_ids: - f2evcrm9ti79******** status: READY source_snapshot_id: fd81qi89ldop******** disk_placement_policy: {} hardware_generation: legacy_features: pci_topology: PCI_TOPOLOGY_V2For more information about the
yc compute disk createcommand, see this CLI reference. -
-
Get a list of disks in the default folder:
yc compute disk listResult:
+----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+ | ID | NAME | SIZE | ZONE | STATUS | INSTANCE IDS | PLACEMENT GROUP | DESCRIPTION | +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+ | a7lqgbt0bb9s******** | first-disk | 20401094656 | ru-central1-a | READY | a7lcvu28njbh******** | | | | a7lv5j5hm1p1******** | second-disk | 21474836480 | ru-central1-a | READY | | | | +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+Get the same list with more details in YAML format:
yc compute disk list --format yamlResult:
- id: epd73ra2mrd4******** folder_id: b1gt6g8ht345******** created_at: "2025-06-23T16:57:01Z" name: first-disk description: my first disk type_id: network-hdd zone_id: ru-central1-a size: "21474836480" block_size: "4096" product_ids: - f2evcrm9ti79******** status: READY source_snapshot_id: fd81qi89ldop******** disk_placement_policy: {} hardware_generation: legacy_features: pci_topology: PCI_TOPOLOGY_V1 - id: epd8lmcncidv******** folder_id: b1gt6g8ht345******** created_at: "2025-06-23T06:32:26Z" name: second-disk type_id: network-ssd zone_id: ru-central1-a size: "21474836480" block_size: "4096" product_ids: - f2evcrm9ti79******** status: READY source_image_id: fd80j21lmqar******** instance_ids: - epdm2ene322e******** disk_placement_policy: {} hardware_generation: legacy_features: pci_topology: PCI_TOPOLOGY_V1
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
Define the parameters of the
yandex_compute_diskresource in the configuration file.Here is an example of the configuration file structure:
resource "yandex_compute_disk" "my-disk" { name = "<disk_name>" zone = "<availability_zone>" snapshot_id = "<snapshot_ID>" hardware_generation { legacy_features { pci_topology = "<PCI_topology>" } } }Where:
-
name: Disk name. Follow these naming requirements:- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
zone: Availability zone of the new disk. -
snapshot_id: ID of the snapshot you are creating the disk based on. -
hardware_generation: Settings describing the virtualized hardware generation assigned to the disk. This is an optional parameter. It includes the following blocks of settings:-
legacy_features: Settings with the description of parameters forGen 1:-
pci_topology: Selecting the PCI topology. The possible values are:PCI_TOPOLOGY_V1PCI_TOPOLOGY_V2
The
legacy_featuresandgeneration2_featuressections are mutually exclusive. -
Note
If the
hardware_generationsettings are not specified, the disk will get the same hardware generation assigned as the source snapshot. -
For more information about the
yandex_compute_diskresource, see the relevant provider documentation. -
-
Make sure the configuration files are correct.
-
In the command line, navigate to the directory where you created the configuration file.
-
Run a check using this command:
terraform plan
If the configuration description is correct, the terminal will display a list of the resources being created and their settings. If the configuration contains any errors, Terraform will point them out.
-
-
Deploy the cloud resources.
-
If the configuration does not contain any errors, run this command:
terraform apply -
Confirm creating the resources.
This will create all the resources you need in the specified folder. You can check the new resources and their settings using the management console
. -
- Get a list of snapshots using the list REST API method for the Snapshot resource or the SnapshotService/List gRPC API call.
- Create a disk using the create REST API method for the Disk resource or the DiskService/Create gRPC API call. In your request, specify the source snapshot ID, and optionally the required hardware generation in the
hardwareGenerationobject (hardware_generationif using the gRPC API).
Once created, the disk will get the CREATING status. Wait until the disk status changes to READY before using it.