Skip to content

Instantly share code, notes, and snippets.

View leocomelli's full-sized avatar
🏠
Working from home

Leonardo Comelli leocomelli

🏠
Working from home
  • Matão/SP - Brazil
  • 22:39 (UTC -03:00)
View GitHub Profile
@leocomelli
leocomelli / gcp_compute_mount_persistent_disk.sh
Created March 31, 2020 04:19 — forked from raj-saxena/gcp_compute_mount_persistent_disk.sh
Use the following script to mount a persistent storage during startup. This is helpful when you provision the compute instance as well as the persistent disk using some automation tool like Terraform. StackOverFlow question - https://stackoverflow.com/questions/53162620/automate-gcp-persistent-disk-initialization
#!/bin/bash
set -euxo pipefail
MNT_DIR=/mnt/disks/persistent_storage
if [[ -d "$MNT_DIR" ]]; then
exit
else
sudo mkfs.ext4 -m 0 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/sdb; \
sudo mkdir -p $MNT_DIR