Deleting a disk
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. Deleting a disk is permanent and cannot be undone, so you cannot recover a deleted disk.
If you delete a disk, its snapshots remain unaffected. Snapshots must be deleted separately.
To delete a disk:
- In the management console, select the folder the disk belongs to.
- Go to Compute Cloud.
- In the left-hand panel, select
Disks. - In the line with the disk, click
and select Delete. - In the window that opens, click Delete.
The folder used by default is the one specified when creating the CLI 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 options.
-
See the description of the CLI commands for deleting disks:
yc compute disk delete --help -
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 | | | | +----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+ -
Select
IDorNAMEof the disk in question. -
Delete the disk:
yc compute disk delete \ --name first-disk
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To delete a disk created with Terraform, follow these steps:
-
In the command line, go to the directory with the Terraform configuration file.
-
Delete the resources using this command:
terraform destroyAlert
Terraform will delete all the resources you created in the current configuration, such as clusters, networks, subnets, and VMs.
-
Type
yesand press Enter.
To delete a disk, use the delete REST API method for the Disk resource or the DiskService/Delete gRPC API call.
To request a list of available disks, use the list REST API method or the DiskService/List gRPC API call.