Last active
September 8, 2015 17:20
-
-
Save dpeterka/60fb94c21b7d999bfdbf to your computer and use it in GitHub Desktop.
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
##### RAID EXAMPLE | |
# Check for mounts | |
disks=($(ls /dev/sd[b-z])) | |
for dev in "${disks[@]}" | |
do | |
disk=$(readlink -f $dev) | |
grep -q ^$disk /proc/mounts && umount $disk | |
grep $dev /etc/fstab && sed -i "\,$dev,d" /etc/fstab | |
done | |
# Cheap hack to make sure device not busy | |
/sbin/udevadm control --stop-exec-queue | |
# Zero drives come pre-formated ext2 | |
for dev in "${disks[@]}" | |
do | |
dd if=/dev/zero of=$dev bs=4096 count=1024 | |
done | |
# RAID | |
mdadm --create /dev/md0 --level=0 --name=cassrd0 --force --raid-devices=${#disks[@]} ${disks[@]} | |
blockdev --setra 512 /dev/md0 | |
udevadm control --start-exec-queue | |
mkfs.ext4 -L cassrd0 /dev/md0 | |
# mount | |
mkdir -p $cassdir | |
echo "LABEL=cassrd0 $cassdir ext4 defaults,noatime 0 0" >> /etc/fstab | |
mount -a | |
#### LV EXAMPLE | |
/sbin/pvcreate /dev/xvdb | |
/sbin/vgcreate elasticsearch-graylog /dev/xvdb | |
EXTENTS=`/sbin/vgdisplay | grep "Total PE" | sed -e 's/Total PE//g' | tr -d " \t\n\r"` | |
/sbin/lvcreate --name esdata -l $EXTENTS elasticsearch-graylog | |
/sbin/mkfs.ext4 /dev/elasticsearch-graylog/esdata | |
mkdir -p $DATA | |
/bin/echo "/dev/elasticsearch-graylog/esdata $DATA ext4 defaults,noatime 0 0" | sudo tee -a /etc/fstab | |
/bin/mount -a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment