Skip to content

Instantly share code, notes, and snippets.

@viet-wego
Last active September 10, 2018 06:09
Show Gist options
  • Save viet-wego/667224c7e41e37f582a0291a2a67cfe3 to your computer and use it in GitHub Desktop.
Save viet-wego/667224c7e41e37f582a0291a2a67cfe3 to your computer and use it in GitHub Desktop.
Create and format new disk on Google Cloud Platform

1. Create new disk:

gcloud compute disks create dev-postgres-master --size=500GB --type=pd-standard

2. Create new instance:

gcloud compute instances create viet-temp

3. Attach new disk to new instance:

gcloud compute instances attach-disk viet-temp --disk=dev-postgres-master

4. SSH to the instance and format the disk:

gcloud compute ssh viet-temp

  • Use this command to list all the disks on this instance:

sudo lsblk

  • Assuming your new disk is /dev/sbd, use these commands to format it
  sudo mkfs.ext4 -m 0 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/sdb
  sudo mkdir -p /data
  sudo mount /dev/sdb /data
  sudo chmod -R 777 /data
  sudo umount /data

5. Detach the disk:

gcloud compute instances detach-disk viet-temp --disk=dev-postgres-master

6. Delete the instance:

gcloud compute instance delete viet-temp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment