Question

Difficulty: MediumManaging Compute Engine Resources

A Cloud Engineer needs to replace a degraded secondary persistent disk attached to a production Compute Engine Virtual Machine (app-server-1) with a restored volume from a recent snapshot named app-data-snapshot-v2. The recovery process must follow Google Cloud recommended practices using gcloud CLI commands to minimize data corruption risk. What is the correct sequence of steps to replace and restore the persistent data disk?

  1. 1Unmount the degraded volume within the guest operating system and detach the disk from app-server-1 using gcloud compute instances detach-disk.
  2. 2Create a new persistent disk in the target zone using gcloud compute disks create with the --source-snapshot=app-data-snapshot-v2 parameter.
  3. 3Attach the newly provisioned persistent disk to app-server-1 using gcloud compute instances attach-disk.
  4. 4Mount the newly attached persistent disk volume to the designated directory path within the guest operating system filesystem.

Answer

The correct operational sequence begins by safely unmounting and detaching the degraded disk from the VM instance, creating a replacement persistent disk from the source snapshot via gcloud compute disks create, attaching the newly created disk to the VM instance via gcloud compute instances attach-disk, and finally mounting the restored volume inside the guest operating system.
To safely restore a data disk onto a Compute Engine VM instance, the operational lifecycle requires disconnecting the old volume first to preserve data integrity, instantiating a new persistent disk resource from the Cloud Storage snapshot, attaching the created disk to the instance via gcloud, and mounting the restored file system within the guest OS.

Step-by-Step Solution

1
Unmount file system and detach old disk
Disk is cleanly disconnected from app-server-1 without active file locks or pending write operations.
Detaching an active disk while mounted can cause file system errors or prevent successful creation/attachment of replacement block devices.
2
Execute gcloud compute disks create with --source-snapshot
A new zonal persistent disk containing data from app-data-snapshot-v2 is provisioned.
Compute Engine persistent disks must be instantiated as independent block resources from snapshots before attachment.
3
Execute gcloud compute instances attach-disk
The new disk becomes available as a block device on app-server-1.
Attaching links the created persistent disk resource to the specific VM compute instance.
4
Mount the volume in the guest OS
Restored file system data is accessible to application workloads.
The guest OS kernel requires mounting the attached block device to expose the file hierarchy.

Key Concept

Restoring Persistent Disks from Snapshots using gcloud CLI
Rate this question