Created
January 8, 2020 13:12
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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