Created
October 13, 2017 16:11
-
-
Save dictvm/d291403b84bb601c3af8d4711344aa61 to your computer and use it in GitHub Desktop.
dirty auto-format/-mount for EBS blockdevices, useful for Terraform-users
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/sh | |
fstab_string='/dev/xvdh /mnt/data ext4 defaults,nofail,nobootwait 0 2' | |
configure() | |
{ | |
echo "Start a service in here, fix permissions or whatever" | |
} | |
# Wait for EBS volume to appear | |
while [ ! -e /dev/xvdh ]; do sleep 1; done | |
# Check if device is formatted already | |
lsblk --output FSTYPE,KNAME | grep "ext4 xvdh" | |
if [ $? -eq 0 ] | |
then | |
echo "Device already formatted." | |
else | |
mkfs.ext4 /dev/xvdh >&2 | |
fi | |
while [ ! -d /mnt/data ]; do configure; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment