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.
- Select 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 specified in the CLI profile is used by default. You can specify a different folder through the --folder-name
or --folder-id
parameter.
-
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 list
Result:
+----------------------+--------------+-------------+-------------------+--------+----------------------+-----------------+-------------+ | 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
ID
orNAME
of the disk in question. -
Delete the disk:
yc compute disk delete \ --name first-disk
If you don't have Terraform, 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 destroy
Alert
Terraform will delete all the resources you created in the current configuration, such as clusters, networks, subnets, and VMs.
-
Type
yes
and 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.