As we discussed the properties and other options available in the persistent disk on the previous post, this section will walk you through creating and attaching a persistent disk onto the existing VM instance. If you want to follow what is a persistent disk in GCE, please go to this link.
Let us assume that we have already created a VM (datacloudies) in the us-central1-a. Now, we want to expand the storage of the instance, which can be done by creating a new disk.
gcloud compute disks create disk1 --size=20GB --zone us-central1-a
Alternatively, you can also create a new disk in web console as well,
Make sure to choose the same region/zone where the instance deployed.
Once the disk is created, it would turn into a ready state. Note that essentially when you are creating the disk, it should be at least 200Gig in size for optimal read and write performance, otherwise you will get a warning.
Let us check in the web console if the new disk information displayed
The next step is to attach the disk1 to the datacloudies instance which is currently running on us-central1-a.
gcloud compute instances attach-disk datacloudies --disk disk1 --zone us-central1-a
Once updated, verify the instance status inside the instance.
We can also login to the instance and verify the attached disk in the hardware device list.
Go to /dev/disk/by-id as a root user and check the attached disk called disk-1.
Congrats!. The new persistent disk is attached to the existing VM instance. The next step is that the disk needs to be formatted. Please follow the post for formatting the persistent disk.