Created
December 11, 2010 12:17
-
-
Save maxp/737343 to your computer and use it in GitHub Desktop.
A Fabric script for striping EBS 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
import commands | |
from fabric.api import * | |
# Globals | |
env.project='EBSSTRIPING' | |
env.user = 'myuser' | |
DEVICES = [ | |
"/dev/sdd", | |
"/dev/sde", | |
"/dev/sdf", | |
"/dev/sdg", | |
] | |
VOL_SIZE = 1 # GB | |
# Tasks | |
def install(): | |
install_packages() | |
create_raid0() | |
create_lvm() | |
mkfs_mount_lvm() | |
def install_packages(): | |
run('DEBIAN_FRONTEND=noninteractive apt-get -y install mdadm') | |
run('apt-get -y install lvm2') | |
run('modprobe dm-mod') | |
def create_raid0(): | |
cmd = 'mdadm --create /dev/md0 --level=0 --chunk=256 --raid-devices=4 ' | |
for device in DEVICES: | |
cmd += '%s ' % device | |
run(cmd) | |
run('blockdev --setra 65536 /dev/md0') | |
def create_lvm(): | |
run('pvcreate /dev/md0') | |
run('vgcreate vgm0 /dev/md0') | |
run('lvcreate --name lvm0 --size %dG vgm0' % VOL_SIZE) | |
def mkfs_mount_lvm(): | |
run('mkfs.xfs /dev/vgm0/lvm0') | |
run('mkdir -p /mnt/lvm0') | |
run('echo "/dev/vgm0/lvm0 /mnt/lvm0 xfs defaults 0 0" >> /etc/fstab') | |
run('mount /mnt/lvm0') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment