Skip to content

Instantly share code, notes, and snippets.

@maximmi
Created March 19, 2021 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximmi/43aaea3c9120e2799b3b66bdaa2066c6 to your computer and use it in GitHub Desktop.
Save maximmi/43aaea3c9120e2799b3b66bdaa2066c6 to your computer and use it in GitHub Desktop.
userdata for EC2 instance to mount volumes
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