Last active
November 13, 2015 02:01
-
-
Save chasebolt/8ac9ef73a55dd388d8e3 to your computer and use it in GitHub Desktop.
cloud-init: run in bootcmd. image is expected to have ephemeral devices letters b-e.
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 -e | |
if lvs ephemeral/data > /dev/null 2>&1; then | |
echo 'lvm already created; exiting' | |
exit 0 | |
fi | |
if ls /dev/xvd* > /dev/null 2>&1; then map='xvd'; fi | |
if ls /dev/sd* > /dev/null 2>&1; then map='sd'; fi | |
if [ -z $map ]; then echo 'no drives found; exiting'; exit 0; fi | |
if ! ls /dev/$map[b-e] > /dev/null 2>&1; then | |
echo 'no ephemeral drives found; exiting' | |
exit 0 | |
fi | |
pvcreate /dev/$map[b-e] | |
vgcreate ephemeral /dev/$map[b-e] | |
lvcreate ephemeral -n data -l 90%FREE | |
mkfs.ext4 /dev/ephemeral/data | |
echo '/dev/ephemeral/data /data ext4 defaults,nofail,comment=cloudconfig 0 0' >> /etc/fstab | |
! [ -d /data ] && mkdir /data | |
mount /data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment