Last active
August 29, 2015 13:56
-
-
Save breu/9051554 to your computer and use it in GitHub Desktop.
swift disk prep
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
# | |
# setup the drives | |
# | |
wget breu.org/filedrop/MegaCli_Linux.zip | |
apt-get -y install unzip | |
unzip -L MegaCli_Linux.zip | |
dpkg -i megacli_linux/megacli_8.07.08-1_all.deb | |
# Get count of adapters | |
/opt/MegaRAID/MegaCli/MegaCli64 -adpCount | |
# Get names of the adapters | |
/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aAll | grep "^Product Name" | |
# Get number of disks on the adapter | |
/opt/MegaRAID/MegaCli/MegaCli64 -PDGetNum -a1 | |
# create a raid0 for each of the unprovisioned disks on adapter 1 | |
/opt/MegaRAID/MegaCli/MegaCli64 -CfgEachDskRaid0 WB Direct NoCachedBadBBU -a1 | |
# check /proc/partitions for disks that have partitions on them and remove them | |
# | |
# do the udev stuff | |
# | |
cat > /etc/udev/rules.d/10-swift.rules << EOF | |
### File: /etc/udev/rules.d/10-swift.rules | |
### | |
### Just adding some information about the controller Dell PERC 810 below | |
### | |
############## HOST6 ################# | |
# Slot: 05:00.0 | |
# Class: RAID bus controller | |
# Vendor: LSI Logic / Symbios Logic | |
# Device: MegaRAID SAS 2208 [Thunderbolt] | |
# SVendor: Dell | |
# SDevice: PERC H810 Adapter | |
# Rev: 05 | |
### Driver: megaraid_sas | |
### Module: megaraid_sas | |
### | |
### Rules for controller H810 | |
EOF | |
for i in $(cat /proc/partitions | grep "^ *[0-9]" | awk '{print $4}' | grep -v "^sda$\|^sda[0-9]$\|^dm"); do | |
echo $i >> partitions.txt | |
done | |
for i in $(cat partitions.txt); do | |
KERNELS=$(udevadm info -a -p $(udevadm info -q path -n $i) | grep -m 1 "KERNELS" | sed 's/^ *KERNELS/KERNELS/g') | |
device_path2=$(echo ${KERNELS} | cut -d '"' -f 2 | cut -d ":" -f 2) | |
device_path3=$(echo ${KERNELS} | cut -d '"' -f 2 | cut -d ":" -f 3) | |
ATTRS=$(udevadm info -a -p $(udevadm info -q path -n $i) | grep "ATTRS{model}" | sed 's/ *"$/"/g' | sed 's/^ *ATTRS/ATTRS/g') | |
echo "${KERNELS},${ATTRS}, ENV{DEVTYPE}==\"disk\", KERNEL==\"sd*\", SYMLINK+=\"c${device_path2}u${device_path3}\"" >> /etc/udev/rules.d/10-swift.rules | |
echo "${KERNELS},${ATTRS}, ENV{DEVTYPE}==\"partition\", KERNEL==\"sd*\", SYMLINK+=\"c${device_path2}u${device_path3}p%n\"" >> /etc/udev/rules.d/10-swift.rules | |
echo "c${device_path2}u${device_path3}" >> format-partitions.txt | |
done | |
udevadm trigger | |
apt-get -y install xfsprogs | |
# | |
# partition and format everything! | |
# | |
for i in $(cat format-partitions.txt); do | |
parted -s /dev/${i} mklabel gpt | |
parted -s /dev/${i} mkpart primary xfs 0% 100% | |
mkfs.xfs -i size=512 -d su=64k,sw=1 -f -L ${i} /dev/${i}p1 | |
mkdir -p /srv/node/${i} | |
echo "LABEL=${i} /srv/node/${i} xfs defaults,noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab | |
done | |
root@XXXXXX-SwiftstorageH2:~# df | |
Filesystem 1K-blocks Used Available Use% Mounted on | |
/dev/mapper/vglocal0020140129-root 329233 243077 69158 78% / | |
udev 16440888 12 16440876 1% /dev | |
tmpfs 6579996 632 6579364 1% /run | |
none 5120 0 5120 0% /run/lock | |
none 16449980 0 16449980 0% /run/shm | |
/dev/mapper/vglocal0020140129-tmp 376807 10254 347097 3% /tmp | |
/dev/sda1 240972 27153 201378 12% /boot | |
/dev/mapper/vglocal0020140129-home 497849960 202632 472358012 1% /home | |
/dev/mapper/vglocal0020140129-usr 8647944 503856 7704792 7% /usr | |
/dev/mapper/vglocal0020140129-var 2882592 433200 2302960 16% /var | |
/dev/sdb1 2928288512 32944 2928255568 1% /srv/node/c2u0 | |
/dev/sdc1 2928288512 32944 2928255568 1% /srv/node/c2u1 | |
/dev/sdd1 2928288512 32944 2928255568 1% /srv/node/c2u2 | |
/dev/sde1 2928288512 32944 2928255568 1% /srv/node/c2u3 | |
/dev/sdf1 2928288512 32944 2928255568 1% /srv/node/c2u4 | |
/dev/sdg1 2928288512 32944 2928255568 1% /srv/node/c2u5 | |
/dev/sdh1 2928288512 32944 2928255568 1% /srv/node/c2u6 | |
/dev/sdi1 2928288512 32944 2928255568 1% /srv/node/c2u7 | |
/dev/sdj1 2928288512 32944 2928255568 1% /srv/node/c2u8 | |
/dev/sdk1 2928288512 32944 2928255568 1% /srv/node/c2u9 | |
/dev/sdl1 2928288512 32944 2928255568 1% /srv/node/c2u10 | |
/dev/sdm1 2928288512 32944 2928255568 1% /srv/node/c2u11 | |
/dev/sdn1 2928288512 32944 2928255568 1% /srv/node/c2u12 | |
/dev/sdo1 2928288512 32944 2928255568 1% /srv/node/c2u13 | |
/dev/sdp1 2928288512 32944 2928255568 1% /srv/node/c2u14 | |
/dev/sdq1 2928288512 32944 2928255568 1% /srv/node/c2u15 | |
/dev/sdr1 2928288512 32944 2928255568 1% /srv/node/c2u16 | |
/dev/sds1 2928288512 32944 2928255568 1% /srv/node/c2u17 | |
/dev/sdt1 2928288512 32944 2928255568 1% /srv/node/c2u18 | |
/dev/sdu1 2928288512 32944 2928255568 1% /srv/node/c2u19 | |
/dev/sdv1 2928288512 32944 2928255568 1% /srv/node/c2u20 | |
/dev/sdw1 2928288512 32944 2928255568 1% /srv/node/c2u21 | |
/dev/sdx1 2928288512 32944 2928255568 1% /srv/node/c2u22 | |
/dev/sdy1 2928288512 32944 2928255568 1% /srv/node/c2u23 | |
/dev/sdz1 2928288512 32944 2928255568 1% /srv/node/c2u24 | |
/dev/sdaa1 2928288512 32944 2928255568 1% /srv/node/c2u25 | |
/dev/sdab1 2928288512 32944 2928255568 1% /srv/node/c2u26 | |
/dev/sdac1 2928288512 32944 2928255568 1% /srv/node/c2u27 | |
/dev/sdad1 2928288512 32944 2928255568 1% /srv/node/c2u28 | |
/dev/sdae1 2928288512 32944 2928255568 1% /srv/node/c2u29 | |
/dev/sdaf1 2928288512 32944 2928255568 1% /srv/node/c2u30 | |
/dev/sdag1 2928288512 32944 2928255568 1% /srv/node/c2u31 | |
/dev/sdah1 2928288512 32944 2928255568 1% /srv/node/c2u32 | |
/dev/sdai1 2928288512 32944 2928255568 1% /srv/node/c2u33 | |
/dev/sdaj1 2928288512 32944 2928255568 1% /srv/node/c2u34 | |
/dev/sdak1 2928288512 32944 2928255568 1% /srv/node/c2u35 | |
/dev/sdal1 2928288512 32944 2928255568 1% /srv/node/c2u36 | |
/dev/sdam1 2928288512 32944 2928255568 1% /srv/node/c2u37 | |
/dev/sdan1 2928288512 32944 2928255568 1% /srv/node/c2u38 | |
/dev/sdao1 2928288512 32944 2928255568 1% /srv/node/c2u39 | |
/dev/sdap1 2928288512 32944 2928255568 1% /srv/node/c2u40 | |
/dev/sdaq1 2928288512 32944 2928255568 1% /srv/node/c2u41 | |
/dev/sdar1 2928288512 32944 2928255568 1% /srv/node/c2u42 | |
/dev/sdas1 2928288512 32944 2928255568 1% /srv/node/c2u43 | |
/dev/sdat1 2928288512 32944 2928255568 1% /srv/node/c2u44 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment