Here’s how to extend an ext4 boot volume.
gcloud compute disks resize DISK_NAME --size DISK_SIZE --zone ZONE --project PROJECTID |
Resize the file system. Example / is on sda3.
growpart /dev/sda 3 resize2fs /dev/sda3 |
cloud engineer
Here’s how to extend an ext4 boot volume.
gcloud compute disks resize DISK_NAME --size DISK_SIZE --zone ZONE --project PROJECTID |
gcloud compute disks resize DISK_NAME --size DISK_SIZE --zone ZONE --project PROJECTID
Resize the file system. Example / is on sda3.
growpart /dev/sda 3 resize2fs /dev/sda3 |
growpart /dev/sda 3 resize2fs /dev/sda3
How to create service account in GCP via Terraform.
provider "google" { project = "your_project_id" } resource "google_service_account" "service_account" { account_id = "your-service-account-name" display_name = "test service account built by terraform" } |
provider "google" { project = "your_project_id" } resource "google_service_account" "service_account" { account_id = "your-service-account-name" display_name = "test service account built by terraform" }
Connect to your CloudShell environment from your terminal.
$ gcloud cloud-shell ssh Welcome to Cloud Shell! Type "help" to get started. first.last@cloudshell $ first.last@cloudshell $ |
$ gcloud cloud-shell ssh Welcome to Cloud Shell! Type "help" to get started. first.last@cloudshell $ first.last@cloudshell $
Once logged in, you can set your project.
first.last@cloudshell $ gcloud config set project $PROJECT_ID |
first.last@cloudshell $ gcloud config set project $PROJECT_ID
Here’s how to move a VM to another VPC.
Stop VM.
gcloud compute instances stop $INSTANCE_NAME \ --zone $ZONE_NAME \ --project $PROJECT_ID |
gcloud compute instances stop $INSTANCE_NAME \ --zone $ZONE_NAME \ --project $PROJECT_ID
Move VM to another VPC.
gcloud compute instances network-interfaces update $INSTANCE_NAME \ --zone $ZONE_NAME \ --network-interface=nic0 \ --network $YOUR_NETWORK \ --subnetwork $YOUR_SUBNETWORK \ --project $PROJECT_ID |
gcloud compute instances network-interfaces update $INSTANCE_NAME \ --zone $ZONE_NAME \ --network-interface=nic0 \ --network $YOUR_NETWORK \ --subnetwork $YOUR_SUBNETWORK \ --project $PROJECT_ID
Start VM.
gcloud compute instances start $INSTANCE_NAME \ --zone $ZONE_NAME \ --project $PROJECT_ID |
gcloud compute instances start $INSTANCE_NAME \ --zone $ZONE_NAME \ --project $PROJECT_ID
How to describe a GCP bucket.
gsutil ls -L -b gs://my-bucket |
gsutil ls -L -b gs://my-bucket
How to find a boot disk from an instance.
gcloud compute instances describe servername \ --format='get(disks[0].source)' \ --zone=us-central1-c \ --project project-id |
gcloud compute instances describe servername \ --format='get(disks[0].source)' \ --zone=us-central1-c \ --project project-id
Result
https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/disks/servername-boot |
https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/disks/servername-boot
Here’s the script to backup GCP disks.
#!/bin/bash now=$(date +%s) disks=$(gcloud compute disks list --project project-id --filter="users:instance" --format="value(name)") for disk in $disks do gcloud compute disks snapshot $disk \ --snapshot-names=$disk-$now \ --zone=us-central1-a \ --project=project-id \ --async done |
#!/bin/bash now=$(date +%s) disks=$(gcloud compute disks list --project project-id --filter="users:instance" --format="value(name)") for disk in $disks do gcloud compute disks snapshot $disk \ --snapshot-names=$disk-$now \ --zone=us-central1-a \ --project=project-id \ --async done
Here’s how to get your project quotas in GCP.
gcloud compute project-info describe --project your-project-id |
gcloud compute project-info describe --project your-project-id