Adding and removing the disk using Cloud Shell.

  • date 12th March, 2021 |
  • by Prwatech |

Attach and detach disks with gcloud compute

Attaching and detaching disks with the gcloud compute command-line tool in Google Cloud Platform (GCP) enables users to manage storage resources for virtual machine (VM) instances efficiently. This capability allows for dynamic adjustments to disk configurations, such as adding additional storage, migrating data, or performing maintenance tasks.

To attach a disk using gcloud compute, users can execute the gcloud compute instances attach-disk command, specifying the target VM instance, the disk to attach, and any additional parameters, such as device names or read/write permissions. This command establishes a connection between the VM and the specified disk, making it available for use within the instance.


Hardware : GCP

Google Account

We can add and remove the disks using GCP cloud shell also.

Open GCP Console.

Click on Activate cloud shell.

$        gcloud compute disks create [diskname] –size [disk-size] –type [disk-type] –zone [zone-name]

To create disk.

Click on Authorize.

$        gcloud compute instances attach-disk [instance-name] –disk [disk-name]

To Attach the disk.

$        gcloud compute disks resize [disk-name] –size [disk-size]

To resize the disk. Type y for resize.

NB: We can increase the size. But we can’t downgrade it.

$        gcloud compute instances detach-disk [instance-name] –disk=[disk-name]

To detach/remove the disk.


Attach and detach disks with gcloud compute


Quick Support

image image