# Deleting a disk

{% note warning %}

You can only delete a disk that is not attached to a virtual machine. To learn how to detach a disk, see [Detaching a disk from a VM](../vm-control/vm-detach-disk.md). Deleting a disk is permanent and cannot be undone, so you cannot recover a deleted disk.

{% endnote %}

If you delete a disk, its snapshots remain unaffected. Snapshots must be [deleted](../snapshot-control/delete.md) separately.

To delete a disk:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the management console, select the folder the disk belongs to.
  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 **Delete**.
  1. In the window that opens, click **Delete**.

- CLI {#cli}

  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 deleting disks:

     ```bash
     yc compute disk delete --help
     ```

  1. Get a list of disks in the default folder:

     ```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. Select `ID` or `NAME` of the disk in question.
  1. Delete the disk:

     ```bash
     yc compute disk delete \
       --name first-disk
     ```

- 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.

  To delete a disk created with Terraform, follow these steps:
  1. In the command line, go to the directory with the Terraform configuration file.
  1. Delete the resources using this command:

     ```bash
     terraform destroy
     ```

     {% note alert %}

     Terraform will delete all the resources you created in the current configuration, such as clusters, networks, subnets, and VMs.

     {% endnote %}

  1. Type `yes` and press **Enter**.

- API {#api}

  To delete a disk, use the [delete](../../api-ref/Disk/delete.md) REST API method for the [Disk](../../api-ref/Disk/index.md) resource or the [DiskService/Delete](../../api-ref/grpc/Disk/delete.md) gRPC API call.

  To request a list of available disks, use the [list](../../api-ref/Disk/list.md) REST API method or the [DiskService/List](../../api-ref/grpc/Disk/list.md) gRPC API call.

{% endlist %}