User Tools

Site Tools


mdadm

Mdadm Helpers

*

Debian Disable/Enable Raid Monthly Checks

dpkg-reconfigure mdadm

or edit cron job

nano /etc/cron.d/mdadm

External Link

How do I replace a disk marked as removed from a linux md raid-5 array

If drives are "hot swap", don't need to power off server/pc...

First identify removed drive:

lsblk
Find serial number, if necessary:
smartctl -a /dev/sdb | grep Serial

If drive is just remved:

mdadm --zero-superblock /dev/sdXn
mdadm /dev/md0 --add /dev/sdXn

If replacing damaged drive, then only:

mdadm /dev/md0 --add /dev/sdXn

Check every drive manually

mdadm --examine /dev/sdX

“not enough to start the array” – error while staring mdadm RAID array

Stop failed array:

mdadm -S /dev/md0

Assemble the pre-existing array:

mdadm -A -f /dev/md0

Test Email Settings

mdadm --monitor --scan --test

If got error: “mdadm: Only one autorebuild process allowed in scan mode, aborting”

mdadm --monitor /dev/md0 --test

Simple Script to read Hdd serial numbers

#!/bin/bash
smartctl -a /dev/sda | grep -i 'Serial';
echo "";
echo "";

for i in {a..z} ; do
echo $i
smartctl -a /dev/sd$i | grep -i 'Serial';
done

A SparesMissing event had been detected on md device

Removing the spares=1 option or just recreating the mdadm.conf from scratch fixes the problem:

**Update MDADM config file**

/usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf.copy

Double check new configuration ad then save as mdadm.conf

**Just in case**

Run

update-initramfs -u

Speed Up or Slow Down Raid rebuild

To see current limits, enter:

sysctl dev.raid.speed_limit_min
sysctl dev.raid.speed_limit_max

To change minimal speed (ex. min.= 10000), enter:

echo value > /proc/sys/dev/raid/speed_limit_min

or

sysctl -w dev.raid.speed_limit_min=value

To change maximal speed (ex. max.= 200000), enter:

echo value > /proc/sys/dev/raid/speed_limit_max

or

sysctl -w dev.raid.speed_limit_max=value

If you want to override the defaults you could add these two lines to:

nano /etc/sysctl.conf

#################NOTE ################
##  You are limited by CPU and memory too #
###########################################
dev.raid.speed_limit_min = 50000
## good for 4-5 disks based array ##
dev.raid.speed_limit_max = 2000000
## good for large 6-12 disks based array ###
dev.raid.speed_limit_max = 5000000

Source: External Link

Speed Change Script Example

#!/bin/bash
clear;
speed=$(cat /proc/sys/dev/raid/speed_limit_max)
echo ""
echo -e "\e[92m *\e[0m Speed Was: \e[92m$speed\e[0m"
echo ""
echo -e "\e[92m *\e[0m Switching to:\e[0m"
tput setaf 2
tput bold
if [[ $speed == '150000' ]]; then
    sysctl -w dev.raid.speed_limit_max=10000 | cut -c 28- | sed  -e   's/^/                 /'
    sysctl -w dev.raid.speed_limit_min=1000  | cut -c 28- | sed  -e   's/^/                 /'
else
    sysctl -w dev.raid.speed_limit_max=150000 | cut -c 28- | sed  -e 's/^/                 /'
    sysctl -w dev.raid.speed_limit_min=10000  | cut -c 28- | sed  -e   's/^/                 /'
fi

tput sgr0

mdadm.txt · Last modified: 2024/02/09 04:29 by norman