[Yandex Cloud documentation](../../../index.md) > [Yandex Compute Cloud](../../index.md) > [Step-by-step guides](../index.md) > Disk snapshots > Creating a snapshot

# Creating a disk snapshot


A _disk snapshot_ is a copy of the disk file system at a specific point in time.

You can create snapshots of network [disks](../../concepts/disk.md#disks_types) 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](../../concepts/dedicated-host.md), use [Yandex Cloud Backup](../../../backup/index.md). This service supports Ubuntu, CentOS, CentOS Stream, and Windows Server.

## Preparation steps {#prepare}

A disk snapshot only contains the data that was written to the disk at the time its snapshot was created. If the disk is attached to a running VM, the OS and app cache will not be included in the snapshot.

To ensure the snapshot data integrity:

{% list tabs group=operating_system %}

- Linux {#linux}

  1. Stop all disk write operations in applications.

  1. Write the OS cache to the disk:

      ```bash
      sync
      ```

  1. Freeze the file system:

      ```bash
      sudo fsfreeze --freeze <mount_point>
      ```
      Where `--freeze` is the parameter to freeze the file system. Replace `<mount_point>` with the folder where the file system is mounted, e.g., `/mnt/vdc2`.

  1. Create a snapshot by following the steps [below](#create).

  1. Unfreeze the file system:

      ```bash
      sudo fsfreeze --unfreeze <mount_point>
      ```
      Where `--unfreeze` is the parameter to unfreeze the file system. Replace `<mount_point>` with the folder where the file system is mounted, e.g., `/mnt/vdc2`.

- Other operating systems {#other}

  1. Stop the VM (see [Stopping](../vm-control/vm-stop-and-start.md#stop)).
  1. Wait until the VM status changes to `STOPPED`.

{% endlist %}

## Creating a snapshot {#create}

{% note info %}

The disk snapshot you create will get assigned the [virtualized hardware generation](../../concepts/hardware-generations.md) on which a VM instance can be deployed from this snapshot. You can assign to a snapshot a generation different from the one assigned to the source disk using the [Yandex Cloud CLI](../../../cli/index.md), [Terraform](../../../tutorials/infrastructure-management/terraform-quickstart.md), or [API](../../../api-design-guide/index.md).

{% endnote %}

To create a disk snapshot:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder containing the disk.
  1. Navigate to **Compute Cloud**.
  1. In the left-hand panel, select ![image](../../../_assets/console-icons/hard-drive.svg) **Disks**.
  1. In the line with the disk, click ![image](../../../_assets/console-icons/ellipsis.svg) and select **Create snapshot**.
  1. Enter a name for the snapshot. The naming requirements are as follows:

      * Length: between 3 and 63 characters.
      * It can only contain lowercase Latin letters, numbers, and hyphens.
      * It must start with a letter and cannot end with a hyphen.

  1. Provide a description for the snapshot, if required.
  1. Click **Create**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  1. See the description of the CLI commands for creating snapshots:

      ```bash
      yc compute snapshot create --help
      ```

  1. Select the disk to create a snapshot of. To get a list of disks in the default folder, run this command:

      ```bash
      yc compute disk list
      ```
      
      Result:
      
      ```text
      +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+
      |          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  |                      |                 |             |
      +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+
      ```

  1. Create a snapshot in the default folder:

      ```bash
      yc compute snapshot create \
        --name first-snapshot \
        --description "my first snapshot via CLI" \
        --disk-id fhm4aq4hvq5g******** \
        --hardware-generation-id <hardware_generation> \
        --hardware-features pci_topology=<PCI_topology>
      ```

      Where:
      * `--name`: Snapshot name. The naming requirements are as follows:

          * Length: between 3 and 63 characters.
          * It can only contain lowercase Latin letters, numbers, and hyphens.
          * It must start with a letter and cannot end with a hyphen.

      * `--description`: Description of the new snapshot. This is an optional setting.
      * `--disk-id`: ID of the disk to create the snapshot for. Instead of the ID, you can provide its name in `--disk-name`.
      * `--hardware-generation-id`: Virtualized hardware [generation](../../concepts/hardware-generations.md#configurations) assigned to the snapshot. This is an optional setting. The possible values are:

          * `legacy`: `Gen 1`. If you select this generation, you can also specify the PCI topology in the `--hardware-features` parameter.
          * `generation2`: `Gen 2`. If you select this generation, you do not need to specify `--hardware-features`.

          If not specified, the snapshot will get the same hardware generation assigned as the source disk.
      * `--hardware-features`: Additional settings for `Gen 1`. This is an optional setting. The possible values are:

          * `pci_topology=v1`: `PCI_TOPOLOGY_V1` topology.
          * `pci_topology=v2`: Adopts the `PCI_TOPOLOGY_V2` topology.

          If the source disk has `Gen 2` assigned, by default, the new snapshot will get `--hardware-features` set to `pci_topology=v1`.

          If the source disk has `Gen 1` assigned, by default, the new snapshot will get the same `--hardware-features` value as the source disk.

      Result:

      ```text
      done (19s)
      id: fd81qi89ldop********
      folder_id: b1gt6g8ht345********
      created_at: "2025-06-23T09:56:04Z"
      name: first-snapshot
      description: my first snapshot via CLI
      storage_size: "3116367872"
      disk_size: "21474836480"
      product_ids:
        - f2evcrm9ti79********
      status: READY
      source_disk_id: epd8lmcncidv********
      hardware_generation:
        legacy_features:
          pci_topology: PCI_TOPOLOGY_V2
      ```

- Terraform {#tf}

  If you do not have Terraform yet, [install it and configure the Yandex Cloud provider](../../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
  
  
  To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), [authenticate](../../../terraform/authentication.md) using the appropriate method.

  1. Define the parameters of the `yandex_compute_snapshot` resource in the configuration file.

     Here is an example of the configuration file structure:
     
     ```hcl
     resource "yandex_compute_snapshot" "snapshot-1" {
       name           = "disk-snapshot"
       source_disk_id = "<disk_ID>"
       hardware_generation {
         legacy_features {
           pci_topology = "<PCI_topology>"
         }
       }
     }
     ```

      Where:
      * `name`: Snapshot name. The naming requirements are as follows:

          * Length: between 3 and 63 characters.
          * It can only contain lowercase Latin letters, numbers, and hyphens.
          * It must start with a letter and cannot end with a hyphen.

      * `source_disk_id`: ID of the disk to create the snapshot for.
      * `hardware_generation`: Block of settings describing the virtualized hardware [generation](../../concepts/hardware-generations.md#configurations) assigned to the snapshot. This is an optional setting. It includes the following blocks of settings:

          * `legacy_features`: Settings with the description of parameters for `Gen 1`:
          
              * `pci_topology`: Selecting the PCI topology. The possible values are:
          
                  * `PCI_TOPOLOGY_V1`
                  * `PCI_TOPOLOGY_V2`
          
              The `legacy_features` and `generation2_features` sections are mutually exclusive.
          * `generation2_features`: Settings for `Gen 2`. If you select `Gen 2`, you do not need to specify any additional settings.
          
              The `generation2_features` and `legacy_features` sections are mutually exclusive.

          {% note info %}

          If the `hardware_generation` settings are not specified, the snapshot will get the same hardware generation assigned as the source disk.

          {% endnote %}

     For more information about `yandex_compute_snapshot`, see [this provider guide](../../../terraform/resources/compute_snapshot.md).

  1. Make sure the configuration files are correct.

     1. In the terminal, navigate to the directory where you created your configuration file.
     1. Run a check using this command:

        ```bash
        terraform plan
        ```

     If the configuration is correct, the terminal will display a list of the resources and their settings. Otherwise, Terraform will show any detected errors. 

  1. Deploy the cloud resources.

     1. If the configuration is correct, run this command:

        ```bash
        terraform apply
        ```

     1. 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](https://console.yandex.cloud).

- API {#api}

  1. Get a list of disks using the [list](../../api-ref/Disk/list.md) REST API method for the [Disk](../../api-ref/Disk/index.md) resource or the [DiskService/List](../../api-ref/grpc/Disk/list.md) gRPC API call.
  1. Create a snapshot using the [create](../../api-ref/Snapshot/create.md) REST API method for the [Snapshot](../../api-ref/Snapshot/index.md) resource or the [SnapshotService/Create](../../api-ref/grpc/Snapshot/create.md) gRPC API call. In your request, specify the source disk ID, and optionally the desired virtualized hardware [generation](../../concepts/hardware-generations.md#configurations) in the [`hardwareGeneration` object](../../api-ref/Snapshot/create.md#yandex.cloud.compute.v1.HardwareGeneration) ([`hardware_generation`](../../api-ref/grpc/Snapshot/create.md#yandex.cloud.compute.v1.HardwareGeneration) if using the gRPC API).

{% endlist %}

HDD or SSD snapshots are created asynchronously. The snapshot is created as soon as you run the create command and gets the `Creating` status. You can now resume writing data to the disk, as further disk operations will not affect the data in the snapshot.

Once the snapshot creation is complete, the snapshot status will change to `Ready`. You can now use the snapshot to create images, disks, and more.

{% note alert %}

When creating a snapshot or image in Linux, the UUID and PARTUUID of disk partitions are saved. Linux uses this data when mounting partitions, including the root one, so these IDs must be unique. For example, if you clone a boot disk and attach it to the same VM, the VM will have two partitions with identical UUIDs. As a result, the VM may boot from the root partition of the wrong disk, rather than the one you specified as the boot disk.

To avoid this, attach the disk to the VM and change all duplicate UUIDs. For more information, see [Attaching a disk to a VM](../vm-control/vm-attach-disk.md).

{% endnote %}


#### Useful links {#see-also}

* [Creating a disk snapshot schedule](../snapshot-control/create-schedule.md)
* [Recovering a disk from a snapshot](../disk-create/from-snapshot.md)