Managing Partition Tables, Partitions, LVM VGs/PVs/LVs, and Filesystems
For all of my servers I'm currently running in EC2, I have the following process:
# create partition label parted /dev/xvdb mklabel gpt # create partition filling disk parted /dev/xvdb mkpart primary 2048s 100% # install LVM [apt-get|yum] install lvm2 if [ centos ]; then service lvm2-lvmetad start service lvm2-monitor start fi # create LVM PV pvcreate /dev/xvdb1 # create or extend the LVM volume group if vgdisplay elasticsearch ; then vgextend elasticsearch /dev/xvdb1 else vgcreate elasticsearch /dev/xvdb1 fi # create an LVM LV lvcreate -l 100%FREE -n runtime elasticsearch # install btrfs [apt-get|yum] install [btrfs-tools|btrfs-progs] # create BTRFS filesystem mkfs.btrfs -L "Elastic Search Runtime" /dev/mapper/elasticsearch-runtime # mount the BTRFS filesystem in a temporary directory in order to create subvolume TEMPDIR="$(mktemp -d)" mount -t btrfs -o defaults,ssd,compress=lzo /dev/mapper/elasticsearch-runtime $TEMPDIR # make subvolume btrfs create subvolume $TEMPDIR/root # unmount umount $TEMPDIR rmdir $TEMPDIR # make new directory for mountpoint mkdir -p /srv/elasticsearch # add to fstab echo "/dev/mapper/elasticsearch-runtime /srv/elasticsearch btrfs defaults,ssd,compress=lzo,subvol=root 0 0" >> /etc/fstab # reload mounts mount -a # done
It should be pretty self-evident that this process is painful and sucks. I need this process to run once for every "volume" I create. I have multiple volumes for elasticsearch-data1, elasticsearch-data2, and so on, for which this process is repeated.
I'm having a hard time finding modules in the forge which will do this for me. I've found the LVM module, but then I lose disk alignment with parted and GPT. There's no BTRFS module for creating/managing subvolumes, and no solid module for fstab that I've found. It seems that most Puppet work is considered to start after you've done setup of your machine, which isn't really an option for my current work.
Is there something I'm missing, or do I have to write modules to manage
btrfs, and more, and then just chain the dependencies in order?