Skip to content

Instantly share code, notes, and snippets.

@raj-saxena
Created January 8, 2020 13:12
Show Gist options
  • Save raj-saxena/0f6bcc7329f3a233a671fe09b463255a to your computer and use it in GitHub Desktop.
Save raj-saxena/0f6bcc7329f3a233a671fe09b463255a to your computer and use it in GitHub Desktop.
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.
#!/bin/bash
set -euxo pipefail
if [[ -d "/mnt/disks/persistent_storage" ]]; 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/disks/persistent_storage
sudo mount -o discard,defaults /dev/sdb /mnt/disks/persistent_storage
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment