Last active
August 29, 2015 14:19
-
-
Save salekseev/5fceda65e30091faeb6f to your computer and use it in GitHub Desktop.
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/sh | |
KEY="temp..." | |
echo -n "Number of physical disks this system's RAID controller contains: " | |
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL | egrep '^(Adapter|Product Name|RAID Level Size State|Number Of Drives|Physical Disk|Raw Size|Link Speed|Media Type|Drive Temperature|Slot Number):' | grep 'Raw Size' | wc -l | |
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL | egrep '^(Adapter|Product Name|RAID Level Size State|Number Of Drives|Physical Disk|Raw Size|Link Speed|Media Type|Drive Temperature|Slot Number):' | |
echo | |
read -p "Are you sure you want to continue? <y/N> " prompt | |
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]] | |
then | |
mkdir -p /etc/facter/facts.d | |
rm -f /etc/facter/facts.d/hdp_disks.txt | |
# LUKS format disks | |
for hdp_disk in $(seq 0 11); do | |
echo "Configuring hdp_disk${hdp_disk} ..." | |
pd_disk=$((hdp_disk + 1)) | |
echo "Creating partition on /dev/disk/by-path/pci-0000:02:00.0-scsi-0:2:${pd_disk}:0 ..." | |
parted -s -a optimal /dev/disk/by-path/pci-0000:02:00.0-scsi-0:2:${pd_disk}:0 mklabel gpt | |
parted -s -a optimal /dev/disk/by-path/pci-0000:02:00.0-scsi-0:2:${pd_disk}:0 mkpart primary 0% 100% | |
partprobe /dev/disk/by-path/pci-0000:02:00.0-scsi-0:2:${pd_disk}:0 | |
kpartx -a /dev/disk/by-path/pci-0000:02:00.0-scsi-0:2:${pd_disk}:0 -s | |
echo "Executing luksFormat on /dev/disk/by-path/pci-0000:02:00.0-scsi-0:2:${pd_disk}:0-part1 ..." | |
echo "${KEY}" | cryptsetup --verbose luksFormat /dev/mapper/pci-0000:02:00.0-scsi-0:2:${pd_disk}:0p1 | |
echo "hdp_disk${hdp_disk}=/dev/disk/by-path/pci-0000:02:00.0-scsi-0:2:${pd_disk}:0-part1" >> /etc/facter/facts.d/hdp_disks.txt | |
echo -n $KEY > /etc/luks/hdp_disk${hdp_disk}.key | |
cryptsetup luksOpen --key-file /etc/luks/hdp_disk${hdp_disk}.key /dev/mapper/pci-0000:02:00.0-scsi-0:2:${pd_disk}:0p1 hdp_disk${hdp_disk} | |
echo "Creating filesystem on /dev/mapper/hdp_disk${disk} ..." | |
mkfs -t ext4 -m 1 -O dir_index,extent,sparse_super /dev/mapper/hdp_disk${hdp_disk} | |
mkdir -p /grid/${hdp_disk} | |
mount /dev/mapper/hdp_disk${hdp_disk} /grid/${hdp_disk} | |
echo | |
done | |
else | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment