-
Notifications
You must be signed in to change notification settings - Fork 0
RAID
Vlad edited this page Jul 7, 2020
·
6 revisions
# Check disks
sudo fdisk -l
# OR
sudo lsblk
# Install Ubuntu Packages
sudo apt-get update && sudo apt-get -y install lvm2 mdadm
# Install CentOS packages
sudo yum update -y && sudo yum install -y lvm2 mdadm
# Check block details
sudo mdadm --examine /dev/sd[a-i]1 # or /dev/sd[acde]1
# Create RAID partition on each disk
sudo fdisk /dev/sdb
# > d (delete partitions)
# > n (create partition)
# > t (change partition type; find it with `L`; Linux RAID is 29)
# > w (write changes)
# Examine partitions
sudo mdadm --examine /dev/sd[b-i]
# Create RAID10
sudo mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/sd[bcde]1
# Create RAID5 (7+1 disks)
sudo mdadm --create /dev/md5 --level=5 --raid-devices=8 /dev/sd[b-i]1
# Check info
sudo mdadm --detail /dev/md0
sudo mdadm --detail /dev/md5
# Watch resync progress
watch -n1 cat /proc/mdstat
# Tune minimum resync speed (bring back to initial value after, which is 1000 so it does not impact performance)
sudo sysctl dev.raid.speed_limit_min # Check value (default is 1000)
sudo sysctl -w dev.raid.speed_limit_min=1000000 # Temporary change value
sudo sysctl -w dev.raid.speed_limit_min=1000 # Restore value
# Update mdadm config on Ubuntu
sudo bash /usr/share/mdadm/mkconf | sudo tee /etc/mdadm/mdadm.conf
# Or
sudo mdadm --examine --scan | sudo tee -a /etc/mdadm/mdadm.conf
# Update initramfs
sudo update-initramfs -u
# Update mdadm config on CentOS
sudo mdadm --detail --scan --verbose | sudo tee -a /etc/mdadm.conf
# Create LVM Physical Volume (check with pvdisplay)
sudo pvcreate /dev/md0
# Create Volume Group (check with vgdisplay)
sudo vgcreate data_vg /dev/md0
# Create Logical Volumes (check with lvdisplay)
sudo lvcreate -l +100%FREE -n data_lv data_vg
# Create filesystems
sudo mkfs.ext4 /dev/data_vg/data_lv
# Add to fstab
sudo mkdir -p /data
sudo echo '/dev/data_vg/data_lv /data ext4 defaults 0 2' | sudo tee -a /etc/fstab
# Mount array
sudo mount -a
- https://wiki.archlinux.org/index.php/LVM_on_software_RAID
- http://www.ducea.com/2009/03/08/mdadm-cheat-sheet
- https://www.linuxhelp.com/how-to-configure-raid5-in-centos-7
- https://www.howtoforge.com/how-to-configure-software-raid-to-send-an-email-when-something-is-wrong-with-raid
- https://dustymabe.com/2012/01/29/monitor-raid-arrays-and-get-e-mail-alerts-using-mdadm/