User Tools

Site Tools


mdadm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
mdadm [2022/10/01 11:48] – normanmdadm [2025/06/20 11:25] (current) – [“not enough to start the array” – error while staring mdadm RAID array] norman
Line 1: Line 1:
 ====== Mdadm Helpers ====== ====== Mdadm Helpers ======
 +
 +*************
 +
 +===== Debian Disable/Enable Raid Monthly Checks =====
 +
 +<code>dpkg-reconfigure mdadm</code>
 +
 +or edit cron job
 +
 +<code>nano /etc/cron.d/mdadm</code>
 +
 +[[https://askubuntu.com/questions/1304738/mdadm-checking-raid-5-array-after-each-restart|External Link]]
 +
 +
  
 ===== How do I replace a disk marked as removed from a linux md raid-5 array ===== ===== How do I replace a disk marked as removed from a linux md raid-5 array =====
Line 17: Line 31:
  If **replacing damaged** drive, then only:  If **replacing damaged** drive, then only:
 <code>mdadm /dev/md0 --add /dev/sdXn</code> <code>mdadm /dev/md0 --add /dev/sdXn</code>
 +=== Check every drive manually ===
 +
 +<code>mdadm --examine /dev/sdX</code>
 +
 +====== “not enough to start the array” – error while staring mdadm RAID array ======
 +
 +Stop failed array:
 +<code>mdadm -S /dev/md0</code>
 +
 + Assemble the pre-existing array:
 +<code>mdadm -A -f /dev/md0</code>
 +
 +
 +RUN raid 1 with one disk:
 +<code>
 +mdadm --run /dev/md126
 +</code>
 +
 +Then Add disk:
 +<code>
 +mdadm --manage /dev/md126 --add /dev/sdf4
 +</code>
 +
 +====== Test Email Settings ======
 +
 +<code>mdadm --monitor --scan --test</code>
 +
 +If got error: **"mdadm: Only one autorebuild process allowed in scan mode, aborting"**
 +<code>mdadm --monitor /dev/md0 --test</code>
 +
 +
 +
 +====== Simple Script to read Hdd serial numbers ======
 +
 +<code>#!/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
 +</code>
 +
 +====== 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** ======
 +
 +
 +<code>/usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf.copy</code>
 +
 +Double check new configuration ad then save as mdadm.conf
 +
 +====== **Just in case** ======
 +
 +Run <code>update-initramfs -u</code>
 +====== Speed Up or Slow Down Raid rebuild ======
 +
 +To see current limits, enter:
 +
 +<code>sysctl dev.raid.speed_limit_min
 +sysctl dev.raid.speed_limit_max</code>
 +
 +
 +To change minimal speed (ex. min.= 10000), enter:
 +
 +<code>echo value > /proc/sys/dev/raid/speed_limit_min</code>
 +
 +or 
 +<code>sysctl -w dev.raid.speed_limit_min=value</code>
 +
 +To change maximal speed (ex. max.= 200000), enter:
 +
 +<code>echo value > /proc/sys/dev/raid/speed_limit_max</code>
 +
 +or 
 +<code>sysctl -w dev.raid.speed_limit_max=value</code>
 +
 +
 +If you want to override the defaults you could add these two lines to: <code>nano /etc/sysctl.conf</code>
 +
 +<code>#################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</code>
 +
 +Source: [[https://www.cyberciti.biz/tips/linux-raid-increase-resync-rebuild-speed.html|External Link]]
 +
 +
 +
 +===== Speed Change Script Example =====
 +
 +
 +<code>
 +#!/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
 +</code>
  
mdadm.1664624907.txt.gz · Last modified: by norman