Detaching a disk from a VM
To detach a disk from a VM:
CLI
API
If you don't have the Yandex.Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
View a description of the CLI's detach disk command:
$ yc compute instance detach-disk --help
-
Get a list of VMs in the default folder:
$ yc compute instance list +----------------------+-----------------+---------------+---------+----------------------+ | ID | NAME | ZONE ID | STATUS | DESCRIPTION | +----------------------+-----------------+---------------+---------+----------------------+ | fhm0b28lgfp4tkoa3jl6 | first-instance | ru-central1-a | RUNNING | my first vm via CLI | | fhm9gk85nj7gcoji2f8s | second-instance | ru-central1-a | RUNNING | my second vm via CLI | +----------------------+-----------------+---------------+---------+----------------------+
-
Select the
ID
orNAME
of the VM you need (for example,first-instance
). -
Stop the VM:
$ yc compute instance stop first-instance
-
Get a list of disks attached to the VM:
$ yc compute instance get --full first-instance
-
Choose the
disk_id
of the disk you need (for example,fhm4aq4hvq5g3nepvt9b
). -
Detach the disk:
$ yc compute instance detach-disk first-instance \ --disk-id fhm4aq4hvq5g3nepvt9b
-
Start the VM:
$ yc compute instance start first-instance
Use the detachDisk method for the Instance resource.