GCP Associate Cloud Engineer Practice Question 60: Resize Persistent Disk Online
Google Cloud Associate Cloud Engineer · Test 6 · question 10 of 10
A production Linux VM has a secondary, non-boot persistent disk mounted at /data that is almost full. The application on the VM cannot tolerate any downtime. You need to add capacity to the disk with the least amount of work and without stopping or restarting the VM.
What should you do?
Show answer and explanation
Answer:
A persistent disk can be resized at any time, whether or not it is attached to a running VM, so gcloud compute disks resize (or the equivalent Console action) grows the underlying disk with no downtime. Compute Engine does not automatically grow the partition or file system on a non-boot data disk, so the remaining step is to run the guest OS tools that extend the partition (growpart) and then the file system (resize2fs for ext4 or xfs_growfs for XFS) while the disk stays mounted.
Option A stops and restarts the VM, which is unnecessary and violates the no-downtime requirement; disk resizing does not require the VM to be stopped. Option B is a much larger amount of work (snapshot, restore, detach, reattach) to reach the same result and still causes an interruption while the disks are swapped. Option D adds a second disk and uses LVM to span it with the original disk instead of simply growing the existing disk in place; it works but is far more configuration than the task requires and changes the storage layout the application relies on.
Reference: Resize a persistent disk