raid config added (raid 5 with 3 disk)
This commit is contained in:
parent
456f4b3d48
commit
7a8782f42e
|
@ -0,0 +1,79 @@
|
|||
#!/bin/bash
|
||||
|
||||
#sources:
|
||||
#https://wiki.archlinux.org/title/bcache
|
||||
#https://stackoverflow.com/questions/20797819/command-to-change-the-default-home-directory-of-a-user
|
||||
#https://unix.stackexchange.com/questions/156102/optimizing-bcache
|
||||
#https://evilpiepirate.org/git/linux-bcache.git/tree/Documentation/bcache.txt
|
||||
|
||||
#Block devices
|
||||
hdddev0=/dev/sdb
|
||||
hdddev1=/dev/sdc
|
||||
hdddev2=/dev/sdd
|
||||
|
||||
#Name of the raid device:
|
||||
devname=/dev/md0
|
||||
|
||||
#Name of the mounted raid device:
|
||||
mountname=/mnt/raid0
|
||||
|
||||
|
||||
partition_settings="start=2048, type=83"
|
||||
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Please run as root"
|
||||
exit
|
||||
fi
|
||||
|
||||
read -p "Block devices ${hdddev0}, ${hdddev1} and ${hdddev2} will be wiped, are you sure proceed?" -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
while [ -b /dev/bcache0 ]; then
|
||||
echo "Canceld, device /dev/bcache0 is allready present"
|
||||
exit
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Clean disks, remove partition tables... "
|
||||
wipefs -a $hdddev0
|
||||
wipefs -a $hdddev1
|
||||
wipefs -a $hdddev2
|
||||
|
||||
echo "Partition disks... "
|
||||
echo $partition_settings | sfdisk $hdddev0
|
||||
echo $partition_settings | sfdisk $hdddev1
|
||||
echo $partition_settings | sfdisk $hdddev2
|
||||
|
||||
echo
|
||||
echo "Create raid 5... "
|
||||
mdadm --create $devname --level=5 --raid-devices=3 ${hdddev0}1 ${hdddev1}1 ${hdddev2}1
|
||||
|
||||
|
||||
echo
|
||||
echo "Wait until device is ready... "
|
||||
while [ ! -b $devname ]; do sleep 1; done
|
||||
|
||||
echo
|
||||
echo "Format and mount bcache device..."
|
||||
mkfs.ext4 $devname
|
||||
mkdir $mountname
|
||||
mount $devname $mountname
|
||||
echo "$devname $mountname ext4 rw 0 0" >> /etc/fstab
|
||||
|
||||
echo
|
||||
echo "Config default home directory for new users on bcache partition... "
|
||||
echo "home path of exising users will not be moved automaticaly"
|
||||
mkdir $mountname/home
|
||||
echo "#" >> /etc/default/useradd
|
||||
echo "# Modifications:" >> /etc/default/useradd
|
||||
echo "HOME=$mountname/home" >> /etc/default/useradd
|
||||
|
||||
echo
|
||||
echo "Setup successfully finished"
|
||||
|
Loading…
Reference in New Issue