Created
March 19, 2021 07:00
-
-
Save maximmi/43aaea3c9120e2799b3b66bdaa2066c6 to your computer and use it in GitHub Desktop.
userdata for EC2 instance to mount volumes
This file contains 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
user_data = [ | |
"while [ ! -b $(readlink -f /dev/sdh) ]; do echo 'waiting for device /dev/sdh'; sleep 5 ; done", | |
"blkid $(readlink -f /dev/sdh) || mkfs -t ext4 $(readlink -f /dev/sdh)", | |
"e2label $(readlink -f /dev/sdh) sdh-volume", | |
"grep -q ^LABEL=sdh-volume /etc/fstab || echo 'LABEL=sdh-volume /mnt ext4 defaults' >> /etc/fstab", | |
"grep -q \"^$(readlink -f /dev/sdh) /mnt \" /proc/mounts || mount /mnt", | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment