Skip to content

Instantly share code, notes, and snippets.

View Maharshi-Pathak's full-sized avatar

Maharshi Pathak Maharshi-Pathak

View GitHub Profile
@Maharshi-Pathak
Maharshi-Pathak / gcp_compute_mount_persistent_disk.sh
Created July 28, 2023 22:52 — 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 -uxo pipefail
# DISK_NAME = Name of the disk in terraform
# DEVICE_NAME = When $DISK_NAME is mounted in the compute instance at `/dev/`
MOUNT_DIR=/mnt/disks/persistent_storage
# Check if entry exists in fstab
grep -q "$MOUNT_DIR" /etc/fstab
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.