Google Cloud Platform (GCP) provides a straightforward process for leveraging additional disks to enhance storage capacity, separation of data, and improve performance for your virtual machine instances. This concise guide will walk you through the essential steps of creating, attaching, and managing additional disks in GCP.
Table of Contents
- Step1: Creating Additional Disks
- Step2: Attaching Disks to Instances
- Step3: Formatting and Mounting Disks (Linux)
- Conclusion
Step1: Creating Additional Disks
- GCP Console:
- Navigate to the “Compute Engine” section.
- Click on “Disks” in the left navigation menu.
- Press “Create Disk” and specify details like name, size, and type.
- Click “Create” to create the disk.
- Equivalent Command Line (gcloud):
gcloud compute disks create [DISK_NAME] --size=[DISK_SIZE] --zone=[ZONE]
Example:
gcloud compute disks create my-disk --size=100GB --zone=us-central1-a
Step2: Attaching Disks to Instances
- GCP Console:
- Navigate to the “VM instances” page.
- Click “Edit” for the desired instance.
- In the “Additional disks” section, click “Add item” and select the disk.
- Click “Save” to apply the changes.
- Command Line (gcloud):
gcloud compute instances attach-disk [INSTANCE_NAME] --disk=[DISK_NAME] --zone=[ZONE]
Example:
gcloud compute instances attach-disk my-instance --disk=my-disk --zone=us-central1-a
Step3: Formatting and Mounting Disks (Linux)
- List Disks:
lsblk
- Format Disk:
sudo mkfs.ext4 /dev/sdb
- Create Mount Point:
sudo mkdir /mnt/data
- Mount Disk:
sudo mount /dev/sdb /mnt/data
- Persist Mount:
echo '/dev/sdb /mnt/data ext4 defaults 0 0' | sudo tee -a /etc/fstab
Conclusion
Utilizing additional disks in GCP is a simple yet powerful way to scale your storage infrastructure. By following these concise steps, you can efficiently create, attach, and manage disks, tailoring your storage strategy to meet the specific needs of your applications. Whether for increased capacity, performance optimization, or data separation, leveraging additional disks in GCP enhances the flexibility and scalability of your cloud-based solutions.