Managing persistent disks on Google Compute Engine

It can confusing when you have multiple persistent disks on an instance running on Google Compute Engine. For example, a server may have separate disks for the filesystem root, MySQL data, logs, and /tmp. Once you’ve created the Compute Engine disks and attached each one to the instance, how do you know which Compute Engine disk maps to each volume on the instance?

First, describe the instance to see a list of the attached disks:

gcloud compute instances describe my-instance-name
...
disks:
- autoDelete: true
 boot: true
 deviceName: persistent-disk-0
 index: 0
 interface: SCSI
 kind: compute#attachedDisk
 licenses:
 - https://www.googleapis.com/compute/v1/projects/centos-cloud/global/licenses/centos-7
 mode: READ_WRITE
 source: https://www.googleapis.com/compute/v1/projects/project-name/zones/us-east1-b/disks/disk-01
 type: PERSISTENT
- autoDelete: false
 boot: false
 deviceName: persistent-disk-1
 index: 1
 interface: SCSI
 kind: compute#attachedDisk
 mode: READ_WRITE
 source: https://www.googleapis.com/compute/v1/projects/project-name/zones/us-east1-b/disks/disk-02

Note the index of each disk. Then, on your instance, list the disks by ID:

ls -l /dev/disk/by-id/
total 0
lrwxrwxrwx. 1 root root  9 Jul 25 19:53 google-persistent-disk-0 -> ../../sda
lrwxrwxrwx. 1 root root 10 Jul 25 19:53 google-persistent-disk-0-part1 -> ../../sda1
lrwxrwxrwx. 1 root root  9 Jul 25 19:53 google-persistent-disk-1 -> ../../sdb
lrwxrwxrwx. 1 root root  9 Jul 25 19:53 google-persistent-disk-2 -> ../../sdc
lrwxrwxrwx. 1 root root  9 Sep 17 14:05 google-persistent-disk-3 -> ../../sdd
lrwxrwxrwx. 1 root root  9 Jul 25 19:53 google-persistent-disk-4 -> ../../sde

This listing shows you the volume for each disk that is attached.

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.